fix_parallel_mode_nested_execution_v2.patch
application/octet-stream
Filename: fix_parallel_mode_nested_execution_v2.patch
Type: application/octet-stream
Part: 0
Patch
Format: unified
Series: patch v2
| File | + | − |
|---|---|---|
| src/backend/executor/execMain.c | 7 | 0 |
| src/backend/executor/execUtils.c | 2 | 0 |
| src/backend/executor/nodeGather.c | 1 | 1 |
| src/backend/executor/nodeGatherMerge.c | 1 | 1 |
| src/include/nodes/execnodes.h | 1 | 0 |
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 8359beb..09d1781 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -1703,7 +1703,14 @@ ExecutePlan(EState *estate,
use_parallel_mode = false;
if (use_parallel_mode)
+ {
EnterParallelMode();
+ estate->es_use_parallel_mode = true;
+ }
+ else
+ {
+ estate->es_use_parallel_mode = false;
+ }
/*
* Loop until we've processed the proper number of tuples from the plan.
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index ee6c4af..e8c06c7 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -156,6 +156,8 @@ CreateExecutorState(void)
estate->es_epqScanDone = NULL;
estate->es_sourceText = NULL;
+ estate->es_use_parallel_mode = false;
+
/*
* Return the executor state structure
*/
diff --git a/src/backend/executor/nodeGather.c b/src/backend/executor/nodeGather.c
index 8370037..639f4f5 100644
--- a/src/backend/executor/nodeGather.c
+++ b/src/backend/executor/nodeGather.c
@@ -150,7 +150,7 @@ ExecGather(PlanState *pstate)
* Sometimes we might have to run without parallelism; but if parallel
* mode is active then we can try to fire up some workers.
*/
- if (gather->num_workers > 0 && IsInParallelMode())
+ if (gather->num_workers > 0 && estate->es_use_parallel_mode)
{
ParallelContext *pcxt;
diff --git a/src/backend/executor/nodeGatherMerge.c b/src/backend/executor/nodeGatherMerge.c
index 70f33a9..5625b12 100644
--- a/src/backend/executor/nodeGatherMerge.c
+++ b/src/backend/executor/nodeGatherMerge.c
@@ -194,7 +194,7 @@ ExecGatherMerge(PlanState *pstate)
* Sometimes we might have to run without parallelism; but if parallel
* mode is active then we can try to fire up some workers.
*/
- if (gm->num_workers > 0 && IsInParallelMode())
+ if (gm->num_workers > 0 && estate->es_use_parallel_mode)
{
ParallelContext *pcxt;
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index c461134..85313ab 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -507,6 +507,7 @@ typedef struct EState
bool *es_epqTupleSet; /* true if EPQ tuple is provided */
bool *es_epqScanDone; /* true if EPQ tuple has been fetched */
+ bool es_use_parallel_mode; /* can we use parallel workers? */
/* The per-query shared memory area to use for parallel execution. */
struct dsa_area *es_query_dsa;
} EState;