From 3f1787c253967617a0e34fa4bfb7b2ab184ad484 Mon Sep 17 00:00:00 2001 From: Simon Riggs Date: Fri, 13 Jan 2012 12:59:08 +0000 Subject: [PATCH] Minor but necessary improvements to WAL keepalives Fujii Masao --- src/backend/replication/walreceiver.c | 3 ++- src/backend/replication/walsender.c | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index ee595714e7..ee8ba5ec21 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -750,7 +750,8 @@ ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime) walrcv->lastMsgReceiptTime = lastMsgReceiptTime; SpinLockRelease(&walrcv->mutex); - elog(DEBUG2, "sendtime %s receipttime %s replication apply delay %d transfer latency %d", + if (log_min_mesages <= DEBUG2) + elog(DEBUG2, "sendtime %s receipttime %s replication apply delay %d ms transfer latency %d ms", timestamptz_to_str(sendTime), timestamptz_to_str(lastMsgReceiptTime), GetReplicationApplyDelay(), diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 3598e56f9d..3611713434 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -834,7 +834,12 @@ WalSndLoop(void) if (pq_is_send_pending()) wakeEvents |= WL_SOCKET_WRITEABLE; else + { WalSndKeepalive(output_message); + /* Try to flush pending output to the client */ + if (pq_flush_if_writable() != 0) + break; + } /* Determine time until replication timeout */ if (replication_timeout > 0) -- 2.40.0