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.1
Jason Petersen 2018-03-30 12:23:15 -06:00 committed by Jason Petersen
parent f6720b1b99
commit bbf08f1e8d
1 changed files with 12 additions and 8 deletions

View File

@ -127,6 +127,11 @@ multi_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
{ {
result = CreateDistributedPlan(result, originalQuery, parse, result = CreateDistributedPlan(result, originalQuery, parse,
boundParams, plannerRestrictionContext); boundParams, plannerRestrictionContext);
assignRTEIdentities = false;
setPartitionedTablesInherited = true;
AdjustParseTree(parse, assignRTEIdentities, setPartitionedTablesInherited);
} }
} }
PG_CATCH(); PG_CATCH();
@ -136,14 +141,6 @@ multi_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
} }
PG_END_TRY(); PG_END_TRY();
if (needsDistributedPlanning)
{
assignRTEIdentities = false;
setPartitionedTablesInherited = true;
AdjustParseTree(parse, assignRTEIdentities, setPartitionedTablesInherited);
}
/* remove the context from the context list */ /* remove the context from the context list */
PopPlannerRestrictionContext(); PopPlannerRestrictionContext();
@ -971,6 +968,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;
} }