diff options
author | Michael Paquier <michael@paquier.xyz> | 2019-10-18 14:26:29 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2019-10-18 14:26:29 +0900 |
commit | 3f60f690fac1bf375b92cf2f8682e8fe8f690981 (patch) | |
tree | ba0b71b4469919f0f356b9b18aff351697040fa4 /src/backend/replication/logical/worker.c | |
parent | 38ddeab13b4b86161799c097dea4bdf9be60924a (diff) | |
download | postgresql-3f60f690fac1bf375b92cf2f8682e8fe8f690981.tar.gz postgresql-3f60f690fac1bf375b92cf2f8682e8fe8f690981.zip |
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
Diffstat (limited to 'src/backend/replication/logical/worker.c')
-rw-r--r-- | src/backend/replication/logical/worker.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 11e6331f494..ff623036388 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -1089,6 +1089,8 @@ UpdateWorkerStats(XLogRecPtr last_lsn, TimestampTz send_time, bool reply) static void LogicalRepApplyLoop(XLogRecPtr last_received) { + TimestampTz last_recv_timestamp = GetCurrentTimestamp(); + /* * Init the ApplyMessageContext which we clean up after each replication * protocol message. @@ -1107,7 +1109,6 @@ LogicalRepApplyLoop(XLogRecPtr last_received) int len; char *buf = NULL; bool endofstream = false; - TimestampTz last_recv_timestamp = GetCurrentTimestamp(); bool ping_sent = false; long wait_time; |