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 <[email protected]> Author: Shihao Zhong <[email protected]> Author: Álvaro Herrera <[email protected]> Reviewed-by: Antonin Houska <[email protected]> Reviewed-by: Masahiko Sawada <[email protected]> Reviewed-by: Shihao Zhong <[email protected]> Reported-by: Nathan Bossart <[email protected]> Reported-by: Bharath Rupireddy <[email protected]> Reported-by: Nikolay Samokhvalov <[email protected]> Backpatch-through: 19 Discussion: https://postgr.es/m/CALj2ACVAxA9HxvFe8HSspTJ-UO4Aoz%3DkuQdZBeLrod0gqUxH3g%40mail.gmail.com Discussion: https://postgr.es/m/apBpOVZOyqrakEr_@nathan Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/47b5b23a7800e000adebfd8f718e1302df12a7cb 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(-)
