| From: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix REPACK worker startup and shutdown sequences |
| Date: | 2026-09-17 09:47:14 |
| Message-ID: | E1x78i2-000000005gc-3FPU@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Fix REPACK worker startup and shutdown sequences
A REPACK background worker can fail to start for various reasons, but
the REPACK steering process was not handling them correctly. For
instance, the steering process waits on a condition variable, but it
would simply hang if the worker doesn't send the signal. (A signal
would be sent by postmaster, but it would wake up the process only to be
ignored and continue sleeping.) Fix this by splitting the wait in two:
first wait for the worker to attach to the error queue, and then wait on
the condition variable as before.
The shutdown sequence can also get stuck, if the message queue gets full
while trying to shut down (this can apparently happen if the log level
is set to very noisy). Previously the worker would send a signal and
then detach; but the steering process can receive that signal, act on
it, then fail to wake up to handle the detach, sleeping indefinitely.
Fix this by having the worker send a Terminate message, which the
steering process can react to.
Author: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Author: Shihao Zhong <zhong950419(at)gmail(dot)com>
Author: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Reviewed-by: Antonin Houska <ah(at)cybertec(dot)at>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Reviewed-by: Shihao Zhong <zhong950419(at)gmail(dot)com>
Reported-by: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Reported-by: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Reported-by: Nikolay Samokhvalov <nik(at)postgres(dot)ai>
Backpatch-through: 19
Discussion: https://postgr.es/m/CALj2ACVAxA9HxvFe8HSspTJ-UO4Aoz%3DkuQdZBeLrod0gqUxH3g%40mail.gmail.com
Discussion: https://postgr.es/m/apBpOVZOyqrakEr_@nathan
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/16735af3e39eeb6e3a2c2bcc1e4a17eabc74d377
Modified Files
--------------
src/backend/commands/repack.c | 204 +++++++++++++++++++++++++++--------
src/backend/commands/repack_worker.c | 41 ++++---
src/include/libpq/protocol.h | 3 +
3 files changed, 192 insertions(+), 56 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-09-17 10:26:49 | pgsql: Tolerate partial pgstats entries in pgstat_gc_entry_refs() |
| Previous Message | Michael Paquier | 2026-09-17 08:00:24 | pgsql: Fix typos and grammar of some comments |