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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5c06a7ef24c70226db22310b4c6bad546b6f3335

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

Reply via email to