From 8e677024339e4fdbd49faafe0bf835e265eb01de Mon Sep 17 00:00:00 2001 From: Shihao Date: Tue, 29 Sep 2026 21:35:39 -0600 Subject: [PATCH v1 1/2] Detach the parallel DSM segment after the workers have exited DestroyParallelContext() detached the segment before waiting for the workers to exit. A worker that was still starting up then failed to map the segment, or to attach to the DSA or the SharedFileSet in it, and logged an error although the user only cancelled the query. The error queues are still detached before the wait, which is what keeps a worker stuck in error reporting from blocking the leader. --- src/backend/access/transam/parallel.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c index e1806a9a28a..ad77d4315c6 100644 --- a/src/backend/access/transam/parallel.c +++ b/src/backend/access/transam/parallel.c @@ -980,10 +980,20 @@ DestroyParallelContext(ParallelContext *pcxt) } } + /* + * We can't finish transaction commit or abort until all of the workers + * have exited. This means, in particular, that we can't respond to + * interrupts at this stage. + */ + HOLD_INTERRUPTS(); + WaitForParallelWorkersToExit(pcxt); + RESUME_INTERRUPTS(); + /* * If we have allocated a shared memory segment, detach it. This will - * implicitly detach the error queues, and any other shared memory queues, - * stored there. + * implicitly detach any other shared memory queues stored there. Wait + * until the workers are gone, since a worker that is still starting up + * may not have attached to the segment, or to objects in it, yet. */ if (pcxt->seg != NULL) { @@ -1001,15 +1011,6 @@ DestroyParallelContext(ParallelContext *pcxt) pcxt->private_memory = NULL; } - /* - * We can't finish transaction commit or abort until all of the workers - * have exited. This means, in particular, that we can't respond to - * interrupts at this stage. - */ - HOLD_INTERRUPTS(); - WaitForParallelWorkersToExit(pcxt); - RESUME_INTERRUPTS(); - /* Free the worker array itself. */ if (pcxt->worker != NULL) { -- 2.37.1 (Apple Git-137.1)