aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/logical/worker.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/replication/logical/worker.c')
-rw-r--r--src/backend/replication/logical/worker.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index ced1a59ac18..55eecc30359 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1145,6 +1145,7 @@ static void
LogicalRepApplyLoop(XLogRecPtr last_received)
{
TimestampTz last_recv_timestamp = GetCurrentTimestamp();
+ bool ping_sent = false;
/*
* Init the ApplyMessageContext which we clean up after each replication
@@ -1157,6 +1158,7 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
/* mark as idle, before starting to loop */
pgstat_report_activity(STATE_IDLE, NULL);
+ /* This outer loop iterates once per wait. */
for (;;)
{
pgsocket fd = PGINVALID_SOCKET;
@@ -1164,7 +1166,6 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
int len;
char *buf = NULL;
bool endofstream = false;
- bool ping_sent = false;
long wait_time;
CHECK_FOR_INTERRUPTS();
@@ -1175,7 +1176,7 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
if (len != 0)
{
- /* Process the data */
+ /* Loop to process all available data (without blocking). */
for (;;)
{
CHECK_FOR_INTERRUPTS();
@@ -1348,10 +1349,7 @@ LogicalRepApplyLoop(XLogRecPtr last_received)
ereport(ERROR,
(errmsg("terminating logical replication worker due to timeout")));
- /*
- * We didn't receive anything new, for half of receiver
- * replication timeout. Ping the server.
- */
+ /* Check to see if it's time for a ping. */
if (!ping_sent)
{
timeout = TimestampTzPlusMilliseconds(last_recv_timestamp,