mirror of https://github.com/citusdata/citus.git
Fix the crash that happens when using auto_explain extension with recursive queries (#6406)
This crash happens with recursively planned queries. For such queries, subplans are explained via the ExplainOnePlan function of postgresql. This function reconstructs the query description from the plan therefore it expects the ActiveSnaphot for the query be available. This fix makes sure that the snapshot is in the stack before calling ExplainOnePlan. Fixes #2920.fix-flaky-isolation_shard_move_vs_start_metadata_sync
parent
737e2bb1bb
commit
02fd1e6c03
|
@ -201,6 +201,13 @@ CitusExplainScan(CustomScanState *node, List *ancestors, struct ExplainState *es
|
|||
|
||||
ExplainOpenGroup("Distributed Query", "Distributed Query", true, es);
|
||||
|
||||
/*
|
||||
* ExplainOnePlan function of postgres might be called in this codepath.
|
||||
* It requires an ActiveSnapshot being set. Make sure to make ActiveSnapshot available before calling into
|
||||
* Citus Explain functions.
|
||||
*/
|
||||
PushActiveSnapshot(executorState->es_snapshot);
|
||||
|
||||
if (distributedPlan->subPlanList != NIL)
|
||||
{
|
||||
ExplainSubPlans(distributedPlan, es);
|
||||
|
@ -208,6 +215,8 @@ CitusExplainScan(CustomScanState *node, List *ancestors, struct ExplainState *es
|
|||
|
||||
ExplainJob(scanState, distributedPlan->workerJob, es, params);
|
||||
|
||||
PopActiveSnapshot();
|
||||
|
||||
ExplainCloseGroup("Distributed Query", "Distributed Query", true, es);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue