REPACK decoding worker startup/teardown differs from parallel.c

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: alvherre(at)kurilemu(dot)de
Subject: REPACK decoding worker startup/teardown differs from parallel.c
Date: 2026-08-27 16:43:37
Message-ID: apBpOVZOyqrakEr_@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I don't know for sure whether either of these are v19 material, but they
seemed important to at least note:

The startup wait only checks shared->initialized, and the error queue is
attached with a NULL BackgroundWorkerHandle, so a worker that dies before
it attaches leaves the leader waiting indefinitely, holding
ShareUpdateExclusive. Mihail brought this up in February [0], but it
doesn't seem to have been addressed. parallel.c attaches the same way, but
then calls shm_mq_set_handle() once the worker is registered, so the queue
knows which process it's waiting on and can tell us when that process is
gone. IIUC this issue can only happen when fork() fails.

For teardown, we wait for the worker to exit under HOLD_INTERRUPTS and only
then detach the error queue. A worker blocked writing into a full queue
waits for the leader to read from it, while the leader is waiting for the
worker to exit, so nobody moves. DestroyParallelContext() detaches first
to avoid this. I'm not sure if this is reachable in practice.

[0] https://postgr.es/m/CADzfLwXJLypkRdpwapQr%2BpZQnv1-NvkJ9DpzWhNwudQgirCE0Q%40mail.gmail.com

--
nathan

Browse pgsql-hackers by date

  From Date Subject
Next Message Jingtang Zhang 2026-08-27 16:46:01 Re: Allow aggressive VACUUM to freeze without a cleanup lock
Previous Message Bharath Rupireddy 2026-08-27 16:41:49 REPACK (CONCURRENTLY) backend waits indefinitely when decoding worker fails to start