From 69b7854a92e69ec5300618192e0110e805ed909c Mon Sep 17 00:00:00 2001 From: wangw Date: Fri, 21 Jan 2022 11:05:23 +0800 Subject: [PATCH] Simple modification of timing --- src/backend/replication/logical/reorderbuffer.c | 4 ++++ src/backend/replication/walsender.c | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index d317a626e1..af5026deaa 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -2073,6 +2073,7 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, } ReorderBufferIterTXNInit(rb, txn, &iterstate); + elog(LOG, "begin load changes"); while ((change = ReorderBufferIterTXNNext(rb, iterstate)) != NULL) { Relation relation = NULL; @@ -2437,7 +2438,10 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, if (rbtxn_prepared(txn)) rb->prepare(rb, txn, commit_lsn); else + { rb->commit(rb, txn, commit_lsn); + elog(LOG, "commit the log"); + } } /* this is just a sanity check against bad output plugin behaviour */ diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 39f985ddf3..ad1b8811e7 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -3612,6 +3612,8 @@ static void WalSndKeepaliveIfNecessary(void) { TimestampTz ping_time; + TimestampTz now; + static TimestampTz last_send_keepalive=0; /* * Don't send keepalive messages if timeouts are globally disabled or @@ -3628,11 +3630,13 @@ WalSndKeepaliveIfNecessary(void) * from the standby, send a keep-alive message to the standby requesting * an immediate reply. */ - ping_time = TimestampTzPlusMilliseconds(last_reply_timestamp, + ping_time = TimestampTzPlusMilliseconds(last_send_keepalive, wal_sender_timeout / 2); - if (last_processing >= ping_time) + now = GetCurrentTimestamp(); + if (now >= ping_time) { - WalSndKeepalive(true); + last_send_keepalive = now; + WalSndKeepalive(false); /* Try to flush pending output to the client */ if (pq_flush_if_writable() != 0) -- 2.18.4