diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 8bef3fbdaf..d197aae82e 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2773,6 +2773,8 @@ XLogSendLogical(void)
 
 	if (record != NULL)
 	{
+		XLogRecPtr flushPtr = GetFlushRecPtr();
+
 		/*
 		 * Note the lack of any call to LagTrackerWrite() which is handled by
 		 * WalSndUpdateProgress which is called by output plugin through
@@ -2781,6 +2783,13 @@ XLogSendLogical(void)
 		LogicalDecodingProcessRecord(logical_decoding_ctx, logical_decoding_ctx->reader);
 
 		sentPtr = logical_decoding_ctx->reader->EndRecPtr;
+
+		/*
+		 * If we've sent a record that is at or beyond the flushed point,
+		 * we've caught up.
+		 */
+		if (sentPtr >= flushPtr)
+			WalSndCaughtUp = true;
 	}
 	else
 	{
