Re: Call EndCopyFrom() after initial table sync in logical replication

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Shinya Kato <shinya11(dot)kato(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Call EndCopyFrom() after initial table sync in logical replication
Date: 2026-05-07 15:04:27
Message-ID: CAHGQGwEpwuq9U=Hhx3BbfGY-RrJ5rFvdQopO+0xyAuLVsMdfWA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, May 4, 2026 at 4:58 PM Shinya Kato <shinya11(dot)kato(at)gmail(dot)com> wrote:
>
> Hi hackers,
>
> While reading the logical replication initial table sync code, I
> noticed that copy_table() calls BeginCopyFrom() and CopyFrom() but
> never calls the matching EndCopyFrom().
>
> EndCopyFrom() calls pgstat_progress_end_command(), which resets
> st_progress_command to PROGRESS_COMMAND_INVALID. Without that call,
> the backend status entry continues to report an active COPY operation
> while the tablesync worker proceeds to WAL catchup. As a result,
> pg_stat_progress_copy shows a stale entry for the entire WAL catchup
> phase.
>
> Attached patch adds EndCopyFrom(cstate) immediately after
> CopyFrom(cstate) returns.

Thanks for the patch! It looks good to me.
Barring any objections, I will commit the patch.

Regards,

--
Fujii Masao

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-05-07 15:19:03 Re: Broken build on macOS (Universal / Intel): cpuid instruction not available
Previous Message Tobias Bussmann 2026-05-07 14:57:50 Re: Broken build on macOS (Universal / Intel): cpuid instruction not available