]> granicus.if.org Git - postgresql/commitdiff
Be less aggressive in asking for feedback of logical walsender clients.
authorAndres Freund <andres@anarazel.de>
Tue, 12 Aug 2014 09:04:50 +0000 (11:04 +0200)
committerAndres Freund <andres@anarazel.de>
Tue, 12 Aug 2014 09:05:46 +0000 (11:05 +0200)
When doing logical decoding using START_LOGICAL_REPLICATION in a
walsender process the walsender sometimes was sending out keepalive
messages too frequently. Asking for feedback every time.

WalSndWaitForWal() sends out keepalive messages when it's waiting for
new WAL to be generated locally when it sees that the remote side
hasn't yet flushed WAL up to the local position. That generally is
good but causes problems if the remote side only writes but doesn't
flush changes yet. So check for both remote write and flush position.

Additionally we've asked for feedback to the keepalive message which
isn't warranted when waiting for WAL in contrast to preventing
timeouts because of wal_sender_timeout.

Complaint and patch by Steve Singer.

src/backend/replication/walsender.c

index 318979342ebb593514ec6aac0ffbdc0b25813f6a..844a5dea1def123b6a9c8a75e2bd311c775bd92b 100644 (file)
@@ -1203,9 +1203,11 @@ WalSndWaitForWal(XLogRecPtr loc)
                 * possibly are waiting for a later location. So we send pings
                 * containing the flush location every now and then.
                 */
-               if (MyWalSnd->flush < sentPtr && !waiting_for_ping_response)
+               if (MyWalSnd->flush < sentPtr &&
+                       MyWalSnd->write < sentPtr &&
+                       !waiting_for_ping_response)
                {
-                       WalSndKeepalive(true);
+                       WalSndKeepalive(false);
                        waiting_for_ping_response = true;
                }