aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2020-01-31 10:25:34 +1300
committerThomas Munro <tmunro@postgresql.org>2020-01-31 11:12:21 +1300
commit2c56b3ac436db2d24aa11bdd22f45becf2030607 (patch)
tree8ff6f920b41483110cc07e15dd52a7d864a3e055
parenta5b652f3a0110f81d2433855ab6bec136f92db83 (diff)
downloadpostgresql-2c56b3ac436db2d24aa11bdd22f45becf2030607.tar.gz
postgresql-2c56b3ac436db2d24aa11bdd22f45becf2030607.zip
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
-rw-r--r--src/backend/access/nbtree/nbtsort.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index 16f57557776..bc00799b964 100644
--- a/src/backend/access/nbtree/nbtsort.c
+++ b/src/backend/access/nbtree/nbtsort.c
@@ -1256,6 +1256,15 @@ _bt_begin_parallel(BTBuildState *buildstate, bool isconcurrent, int request)
Assert(request > 0);
pcxt = CreateParallelContext("postgres", "_bt_parallel_build_main",
request, true);
+
+ /* If no DSM segment was available, back out (do serial build) */
+ if (pcxt->seg == NULL)
+ {
+ DestroyParallelContext(pcxt);
+ ExitParallelMode();
+ return;
+ }
+
scantuplesortstates = leaderparticipates ? request + 1 : request;
/*