diff options
author | Thomas Munro <tmunro@postgresql.org> | 2020-02-05 12:21:03 +1300 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2020-02-05 12:27:00 +1300 |
commit | d9fe702a2c9843af71419ad0df069859e5581694 (patch) | |
tree | c2f83eefe58210cf566c61d3f9b12a0d084ecb6d /src | |
parent | 7d91b604d9b5d6ec8c19c57a9ffd2f27129cdd94 (diff) | |
download | postgresql-d9fe702a2c9843af71419ad0df069859e5581694.tar.gz postgresql-d9fe702a2c9843af71419ad0df069859e5581694.zip |
Handle lack of DSM slots in parallel btree build, take 2.
Commit 74618e77 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
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/nbtree/nbtsort.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index e6be7bba594..baec5de9993 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -1332,14 +1332,6 @@ _bt_begin_parallel(BTBuildState *buildstate, bool isconcurrent, int request) 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; /* @@ -1383,6 +1375,16 @@ _bt_begin_parallel(BTBuildState *buildstate, bool isconcurrent, int request) /* Everyone's had a chance to ask for space, so now create the DSM */ InitializeParallelDSM(pcxt); + /* If no DSM segment was available, back out (do serial build) */ + if (pcxt->seg == NULL) + { + if (IsMVCCSnapshot(snapshot)) + UnregisterSnapshot(snapshot); + DestroyParallelContext(pcxt); + ExitParallelMode(); + return; + } + /* Store shared build state, for which we reserved space */ btshared = (BTShared *) shm_toc_allocate(pcxt->toc, estbtshared); /* Initialize immutable state */ |