Skip to content

Commit 942e441

Browse files
committed
Prevent parallel index build in a standalone backend.
This can't work if there's no postmaster, and indeed the code got an assertion failure trying. There should be a check on IsUnderPostmaster gating the use of parallelism, as the planner has for ordinary parallel queries. Commit 40d964e got this right, so follow its model of checking IsUnderPostmaster at the same place where we check for max_parallel_maintenance_workers == 0. In general, new code implementing parallel utility operations should do the same. Report and patch by Yulin Pei, cosmetically adjusted by me. Back-patch to v11 where this code came in. Discussion: https://postgr.es/m/HK0PR01MB22747D839F77142D7E76A45DF4F50@HK0PR01MB2274.apcprd01.prod.exchangelabs.com
1 parent caecab2 commit 942e441

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/backend/optimizer/plan/planner.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6090,8 +6090,12 @@ plan_create_index_workers(Oid tableOid, Oid indexOid)
60906090
double reltuples;
60916091
double allvisfrac;
60926092

6093-
/* Return immediately when parallelism disabled */
6094-
if (dynamic_shared_memory_type == DSM_IMPL_NONE ||
6093+
/*
6094+
* We don't allow performing parallel operation in standalone backend or
6095+
* when parallelism is disabled.
6096+
*/
6097+
if (!IsUnderPostmaster ||
6098+
dynamic_shared_memory_type == DSM_IMPL_NONE ||
60956099
max_parallel_maintenance_workers == 0)
60966100
return 0;
60976101

0 commit comments

Comments
 (0)