Skip to content

Commit 47698b4

Browse files
committed
Fix timeout handling in logical replication worker
The timestamp tracking the last moment a message is received in a logical replication worker was initialized in each loop checking if a message was received or not, causing wal_receiver_timeout to be ignored in basically any logical replication deployments. This also broke the ping sent to the server when reaching half of wal_receiver_timeout. This simply moves the initialization of the timestamp out of the apply loop to the beginning of LogicalRepApplyLoop(). Reported-by: Jehan-Guillaume De Rorthais Author: Julien Rouhaud Discussion: https://postgr.es/m/CAOBaU_ZHESFcWva8jLjtZdCLspMj7vqaB2k++rjHLY897ZxbYw@mail.gmail.com Backpatch-through: 10
1 parent 0d9fcba commit 47698b4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/replication/logical/worker.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,8 @@ UpdateWorkerStats(XLogRecPtr last_lsn, TimestampTz send_time, bool reply)
10351035
static void
10361036
LogicalRepApplyLoop(XLogRecPtr last_received)
10371037
{
1038+
TimestampTz last_recv_timestamp = GetCurrentTimestamp();
1039+
10381040
/*
10391041
* Init the ApplyMessageContext which we clean up after each replication
10401042
* protocol message.
@@ -1053,7 +1055,6 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
10531055
int len;
10541056
char *buf = NULL;
10551057
bool endofstream = false;
1056-
TimestampTz last_recv_timestamp = GetCurrentTimestamp();
10571058
bool ping_sent = false;
10581059
long wait_time;
10591060

0 commit comments

Comments
 (0)