8000 Remember asking for feedback during walsender shutdown. · prmdeveloper/postgres@596f936 · GitHub
[go: up one dir, main page]

Skip to content

Commit 596f936

Browse files
committed
Remember asking for feedback during walsender shutdown.
Since 5a991ef we're explicitly asking for feedback from the receiving side when shutting down walsender, if there's not yet replicated data. Unfortunately we didn't remember (i.e. set waiting_for_ping_response to true) having asked for feedback, leading to scenarios in which replies were requested at a high frequency. I can't reproduce this problem on my laptop, I think that's because the problem requires a significant TCP window to manifest due to the !pq_is_send_pending() condition. But since this clearly is a bug, let's fix it. There's quite possibly more wrong than just this though. While fiddling with WalSndDone(), I rewrote a hard to understand comment about looking at the flush vs. the write position. Reported-By: Nick Cleaton, Magnus Hagander Author: Nick Cleaton Discussion: CAFgz3kus=rC_avEgBV=+hRK5HYJ8vXskJRh8yEAbahJGTzF2VQ@mail.gmail.com CABUevExsjROqDcD0A2rnJ6HK6FuKGyewJr3PL12pw85BHFGS2Q@mail.gmail.com Backpatch: 9.4, were 5a991ef introduced the use of feedback messages during shutdown.
1 parent 65c2eeb commit 596f936

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/backend/replication/walsender.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,13 +2488,14 @@ WalSndDone(WalSndSendDataCallback send_data)
24882488
send_data();
24892489

24902490
/*
2491-
* Check a write location to see whether all the WAL have successfully
2492-
* been replicated if this walsender is connecting to a standby such as
2493-
* pg_receivexlog which always returns an invalid flush location.
2494-
* Otherwise, check a flush location.
2491+
* To figure out whether all WAL has successfully been replicated, check
2492+
* flush location if valid, write otherwise. Tools like pg_receivexlog
2493+
* will usually (unless in synchronous mode) return an invalid flush
2494+
* location.
24952495
*/
24962496
replicatedPtr = XLogRecPtrIsInvalid(MyWalSnd->flush) ?
24972497
MyWalSnd->write : MyWalSnd->flush;
2498+
24982499
if (WalSndCaughtUp && sentPtr == replicatedPtr &&
24992500
!pq_is_send_pending())
25002501
{
@@ -2505,7 +2506,10 @@ WalSndDone(WalSndSendDataCallback send_data)
25052506
proc_exit(0);
25062507
}
25072508
if (!waiting_for_ping_response)
2509+
{
25082510
WalSndKeepalive(true);
2511+
waiting_for_ping_response = true;
2512+
}
25092513
}
25102514

25112515
/*

0 commit comments

Comments
 (0)
0