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 <[email protected]>
Author: Nitin Jadhav <[email protected]>
Reviewed-by: Joao Rito <[email protected]>
Reviewed-by: Fujii Masao <[email protected]>
Discussion: 
https://postgr.es/m/[email protected]
Discussion: 
https://postgr.es/m/camm1awy-bps8vpcdyttzo6nzicsrrq0kbarzjktzokhdn_w...@mail.gmail.com
Backpatch-through: 15

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6901568906f9fb86b914cdfd5807b3cb507f9662

Modified Files
--------------
src/backend/replication/walreceiver.c | 2 ++
1 file changed, 2 insertions(+)

Reply via email to