Attempt to address planner context crashes

Both of these are a bit of a shot in the dark. In one case, we noticed
a stack trace where a caller received a null pointer and attempted to
dereference the memory context field (at 0x010). In the other, I saw
that any error thrown from within AdjustParseTree could keep the stack
from being cleaned up (presumably if we push we should always pop).

Both stack traces were collected during times of high memory pressure
and locally reproducing the problem locally or otherwise has been very
tricky (i.e. it hasn't been reproduced reliably at all).
release-7.5
Jason Petersen 2018-03-30 12:23:15 -06:00 committed by velioglu
parent 547c9d3301
commit 8274680f5b
1 changed files with 11 additions and 7 deletions

View File

@ -147,6 +147,10 @@ distributed_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
result = CreateDistributedPlannedStmt(planId, result, originalQuery, parse, result = CreateDistributedPlannedStmt(planId, result, originalQuery, parse,
boundParams, plannerRestrictionContext); boundParams, plannerRestrictionContext);
setPartitionedTablesInherited = true;
AdjustPartitioningForDistributedPlanning(parse,
setPartitionedTablesInherited);
} }
} }
PG_CATCH(); PG_CATCH();
@ -156,13 +160,6 @@ distributed_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
} }
PG_END_TRY(); PG_END_TRY();
if (needsDistributedPlanning)
{
setPartitionedTablesInherited = true;
AdjustPartitioningForDistributedPlanning(parse, setPartitionedTablesInherited);
}
/* remove the context from the context list */ /* remove the context from the context list */
PopPlannerRestrictionContext(); PopPlannerRestrictionContext();
@ -1446,6 +1443,13 @@ CurrentPlannerRestrictionContext(void)
plannerRestrictionContext = plannerRestrictionContext =
(PlannerRestrictionContext *) linitial(plannerRestrictionContextList); (PlannerRestrictionContext *) linitial(plannerRestrictionContextList);
if (plannerRestrictionContext == NULL)
{
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
errmsg("planner restriction context stack was empty"),
errdetail("Please report this to the Citus core team.")));
}
return plannerRestrictionContext; return plannerRestrictionContext;
} }