From 3f86c6138f45f49f09380ec17fc25901f3f6784f Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Sun, 22 Oct 2023 06:59:05 +0000 Subject: [PATCH v2] Remove extraneous break condition in logical slot advance function There exists an extraneous break condition in pg_logical_replication_slot_advance(). When end of WAL or moveto LSN is reached, the main while condition helps to exit the loop, so no separate break condition is needed. In passing, modify the comment atop the while loop by specifying that the loop runs until the requested target LSN has been reached. --- src/backend/replication/slotfuncs.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c index 6035cf4816..4b694a03d0 100644 --- a/src/backend/replication/slotfuncs.c +++ b/src/backend/replication/slotfuncs.c @@ -500,7 +500,7 @@ pg_logical_replication_slot_advance(XLogRecPtr moveto) /* invalidate non-timetravel entries */ InvalidateSystemCaches(); - /* Decode at least one record, until we run out of records */ + /* Decode records until we reach the requested target */ while (ctx->reader->EndRecPtr < moveto) { char *errm = NULL; @@ -523,10 +523,6 @@ pg_logical_replication_slot_advance(XLogRecPtr moveto) if (record) LogicalDecodingProcessRecord(ctx, ctx->reader); - /* Stop once the requested target has been reached */ - if (moveto <= ctx->reader->EndRecPtr) - break; - CHECK_FOR_INTERRUPTS(); } -- 2.34.1