Skip to content

Commit d9fe702

Browse files
committed
Handle lack of DSM slots in parallel btree build, take 2.
Commit 74618e7 added a new check intended to fix a bug, but put it in the wrong place so that parallel btree build was always disabled. Do the check after we've actually tried to create a DSM segment. Back-patch to 11, like the earlier commit. Reviewed-by: Peter Geoghegan Discussion: https://postgr.es/m/CAH2-WzmDABkJzrNnvf%2BOULK-_A_j9gkYg_Dz-H62jzNv4eKQTw%40mail.gmail.com
1 parent 7d91b60 commit d9fe702

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/backend/access/nbtree/nbtsort.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,14 +1332,6 @@ _bt_begin_parallel(BTBuildState *buildstate, bool isconcurrent, int request)
13321332
pcxt = CreateParallelContext("postgres", "_bt_parallel_build_main",
13331333
request);
13341334

1335-
/* If no DSM segment was available, back out (do serial build) */
1336-
if (pcxt->seg == NULL)
1337-
{
1338-
DestroyParallelContext(pcxt);
1339-
ExitParallelMode();
1340-
return;
1341-
}
1342-
13431335
scantuplesortstates = leaderparticipates ? request + 1 : request;
13441336

13451337
/*
@@ -1383,6 +1375,16 @@ _bt_begin_parallel(BTBuildState *buildstate, bool isconcurrent, int request)
13831375
/* Everyone's had a chance to ask for space, so now create the DSM */
13841376
InitializeParallelDSM(pcxt);
13851377

1378+
/* If no DSM segment was available, back out (do serial build) */
1379+
if (pcxt->seg == NULL)
1380+
{
1381+
if (IsMVCCSnapshot(snapshot))
1382+
UnregisterSnapshot(snapshot);
1383+
DestroyParallelContext(pcxt);
1384+
ExitParallelMode();
1385+
return;
1386+
}
1387+
13861388
/* Store shared build state, for which we reserved space */
13871389
btshared = (BTShared *) shm_toc_allocate(pcxt->toc, estbtshared);
13881390
/* Initialize immutable state */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy