diff options
author | Thomas Munro | 2020-01-30 21:25:34 +0000 |
---|---|---|
committer | Thomas Munro | 2020-01-30 21:25:34 +0000 |
commit | 74618e77b43cfce670b4725d5b9a300a2afd12d1 (patch) | |
tree | 8a5ef0d3b334c610806aa071e7ce8b180070b789 | |
parent | c9d29775195922136c09cc980bb1b7091bf3d859 (diff) |
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.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index f163491d60..e6be7bba59 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -1331,6 +1331,15 @@ _bt_begin_parallel(BTBuildState *buildstate, bool isconcurrent, int request) Assert(request > 0); pcxt = CreateParallelContext("postgres", "_bt_parallel_build_main", request); + + /* If no DSM segment was available, back out (do serial build) */ + if (pcxt->seg == NULL) + { + DestroyParallelContext(pcxt); + ExitParallelMode(); + return; + } + scantuplesortstates = leaderparticipates ? request + 1 : request; /* |