Skip to content

Commit 1fcf62e

Browse files
committed
Handle lack of DSM slots in parallel btree build.
If no DSM slots are available, a ParallelContext can still be created, but its seg pointer is NULL. Teach parallel btree build to cope with that by falling back to a regular non-parallel build, to avoid crashing with a segmentation fault. Back-patch to 11, where parallel CREATE INDEX landed. Reported-by: Nicola Contu Reviewed-by: Peter Geoghegan Discussion: https://postgr.es/m/CA%2BhUKGJgJEBnkuODBVomyK3MWFvDBbMVj%3Dgdt6DnRPU-5sQ6UQ%40mail.gmail.com
1 parent de01777 commit 1fcf62e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/backend/access/nbtree/nbtsort.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,15 @@ _bt_begin_parallel(BTBuildState *buildstate, bool isconcurrent, int request)
13521352
Assert(request > 0);
13531353
pcxt = CreateParallelContext("postgres", "_bt_parallel_build_main",
13541354
request);
1355+
1356+
/* If no DSM segment was available, back out (do serial build) */
1357+
if (pcxt->seg == NULL)
1358+
{
1359+
DestroyParallelContext(pcxt);
1360+
ExitParallelMode();
1361+
return;
1362+
}
1363+
13551364
scantuplesortstates = leaderparticipates ? request + 1 : request;
13561365

13571366
/*

0 commit comments

Comments
 (0)