diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-11-28 12:05:52 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-11-28 12:15:38 -0500 |
commit | 445dbd82a3192c6f4d15de012333943882020904 (patch) | |
tree | 7672981575d47553afb75898b363313475c966c3 /src/backend/access/transam/parallel.c | |
parent | c6755e233be1cccadd0884d952a2bb455fa0db1f (diff) | |
download | postgresql-445dbd82a3192c6f4d15de012333943882020904.tar.gz postgresql-445dbd82a3192c6f4d15de012333943882020904.zip |
Fix ReinitializeParallelDSM to tolerate finding no error queues.
Commit d4663350646ca0c069a36d906155a0f7e3372eb7 changed things so
that shm_toc_lookup would fail with an error rather than silently
returning NULL in the hope that such failures would be reported
in a useful way rather than via a system crash. However, it
overlooked the fact that the lookup of PARALLEL_KEY_ERROR_QUEUE
in ReinitializeParallelDSM is expected to fail when no DSM segment
was created in the first place; in that case, we end up with a
backend-private memory segment that still contains an entry for
PARALLEL_KEY_FIXED but no others. Consequently a benign failure
to initialize parallelism can escalate into an elog(ERROR);
repair.
Discussion: http://postgr.es/m/CA+Tgmob8LFw55DzH1QEREpBEA9RJ_W_amhBFCVZ6WMwUhVpOqg@mail.gmail.com
Diffstat (limited to 'src/backend/access/transam/parallel.c')
-rw-r--r-- | src/backend/access/transam/parallel.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c index 1f542ed8d86..d3431a7c306 100644 --- a/src/backend/access/transam/parallel.c +++ b/src/backend/access/transam/parallel.c @@ -428,9 +428,10 @@ ReinitializeParallelDSM(ParallelContext *pcxt) fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false); fps->last_xlog_end = 0; - /* Recreate error queues. */ + /* Recreate error queues (if they exist). */ error_queue_space = - shm_toc_lookup(pcxt->toc, PARALLEL_KEY_ERROR_QUEUE, false); + shm_toc_lookup(pcxt->toc, PARALLEL_KEY_ERROR_QUEUE, true); + Assert(pcxt->nworkers == 0 || error_queue_space != NULL); for (i = 0; i < pcxt->nworkers; ++i) { char *start; |