Commit 445dbd82 authored by Robert Haas's avatar Robert Haas

Fix ReinitializeParallelDSM to tolerate finding no error queues.

Commit d4663350 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
parent c6755e23
...@@ -428,9 +428,10 @@ ReinitializeParallelDSM(ParallelContext *pcxt) ...@@ -428,9 +428,10 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false); fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
fps->last_xlog_end = 0; fps->last_xlog_end = 0;
/* Recreate error queues. */ /* Recreate error queues (if they exist). */
error_queue_space = 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) for (i = 0; i < pcxt->nworkers; ++i)
{ {
char *start; char *start;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment