From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid delaying WAL receiver shutdown while draining WAL
Date: Thu, 19 Nov 2026 04:31:22 +0000
Message-ID: <E1xTtnt-00000000KvV-2dux@gemulon.postgresql.org> (raw)
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
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/f0f3a041837c706e3db8a5bcd0feb93f518fed00
Modified Files
--------------
src/backend/replication/walreceiver.c | 2 ++
1 file changed, 2 insertions(+)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: fujii@postgresql.org
Subject: Re: pgsql: Avoid delaying WAL receiver shutdown while draining WAL
In-Reply-To: <E1xTtnt-00000000KvV-2dux@gemulon.postgresql.org>
References: <E1xTtnt-00000000KvV-2dux@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox