From 0b866ccf0c9b2745db68b32dfba23f8e1f992944 Mon Sep 17 00:00:00 2001 From: Wang Wei Date: Fri, 10 Mar 2023 13:48:49 +0800 Subject: [PATCH v7 2/6] Check wal_sender_timeout is in effect before using it. --- src/backend/replication/walsender.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 8686f53bb4..bfc5651996 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -1394,8 +1394,9 @@ WalSndWriteData(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid, WalSndShutdown(); /* Try taking fast path unless we get too close to walsender timeout. */ - if (now < TimestampTzPlusMilliseconds(last_reply_timestamp, - wal_sender_timeout / 2) && + if ((wal_sender_timeout <= 0 || + now < TimestampTzPlusMilliseconds(last_reply_timestamp, + wal_sender_timeout / 2)) && !pq_is_send_pending()) { return; @@ -1517,7 +1518,7 @@ WalSndUpdateProgress(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId * for large transactions where we don't send any changes to the * downstream and the receiver can timeout due to that. */ - if (pending_writes || (!end_xact && + if (pending_writes || (!end_xact && wal_sender_timeout > 0 && now >= TimestampTzPlusMilliseconds(last_reply_timestamp, wal_sender_timeout / 2))) ProcessPendingWrites(); -- 2.39.1.windows.1