postgres.git / summary / log / commit / refs

commit    1901aa07eda15591423fe63e414c07dad2f23ec5
Author:   Fujii Masao <fujii@postgresql.org>
Date:     Thu Nov 19 04:27:37 2026 +0000

    Avoid delaying WAL receiver shutdown while draining WAL
    
    Standby shutdown, promotion, and changes to replication connection
    settings could be delayed while the WAL receiver was continuously
    receiving WAL.
    
    The inner receive loop in WalReceiverMain() processed all immediately
    available messages without checking interrupts. If WAL arrived faster
    than the receiver could write it, the receiver could remain in this
    loop with SIGTERM pending, leaving the startup process waiting for it
    to exit.
    
    Fix this by checking interrupts on each iteration of the inner loop so
    that pending shutdown requests are handled even when more WAL is
    available.
    
    Backpatch to all supported versions.
    
    Reported-by: Andres Freund <andres@anarazel.de>
    Author: Nitin Jadhav <nitinjadhavpostgres@gmail.com>
    Reviewed-by: Joao Rito <joaovictor.rito@gmail.com>
    Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
    Discussion: https://postgr.es/m/20210511022755.wcb5h4czadxsgewt@alap3.anarazel.de
    Discussion: https://postgr.es/m/CAMm1aWY-bps8VPCdyTTZo6NZicSRrq0kBArzjKTZoKHdN_wqOA@mail.gmail.com
    Backpatch-through: 15


src/backend/replication/walreceiver.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index e3dfe76cf99..a42db021780 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -537,6 +537,8 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len) */ for (;;) { + CHECK_FOR_INTERRUPTS(); + if (len > 0) { /* [parent: ede2e7e47c3b]