From 14f523601a44f816833dd5e4e0f2326edf533278 Mon Sep 17 00:00:00 2001 From: Shinya Kato Date: Tue, 21 Apr 2026 10:29:07 +0900 Subject: [PATCH v1] Call EndCopyFrom() during initial table sync in logical replication Previously, copy_table() called BeginCopyFrom() and CopyFrom() but omitted the matching EndCopyFrom() call. Without it, the backend status entry continued to report an active COPY operation while the tablesync worker proceeded to WAL catchup, causing pg_stat_progress_copy to show a stale entry for the entire WAL catchup phase, which can be significant for large tables. This commit adds the missing EndCopyFrom() call, which invokes pgstat_progress_end_command() to reset st_progress_command to PROGRESS_COMMAND_INVALID as soon as the COPY phase completes. Author: Shinya Kato Reviewed-by: Discussion: https://postgr.es/m/ --- src/backend/replication/logical/tablesync.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c index eb718114297..a04b84ebc1d 100644 --- a/src/backend/replication/logical/tablesync.c +++ b/src/backend/replication/logical/tablesync.c @@ -1210,6 +1210,7 @@ copy_table(Relation rel) /* Do the copy */ (void) CopyFrom(cstate); + EndCopyFrom(cstate); logicalrep_rel_close(relmapentry, NoLock); } -- 2.47.3