Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 74618e7

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 c9d2977 commit 74618e7

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
@@ -1331,6 +1331,15 @@ _bt_begin_parallel(BTBuildState *buildstate, bool isconcurrent, int request)
13311331
Assert(request > 0);
13321332
pcxt = CreateParallelContext("postgres", "_bt_parallel_build_main",
13331333
request);
1334+
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+
13341343
scantuplesortstates = leaderparticipates ? request + 1 : request;
13351344

13361345
/*

0 commit comments

Comments
 (0)