Re: Orphaned records in pg_replication_origin_status after subscription drop
Amit Kapila <amit.kapila16@gmail.com>
From: Amit Kapila <amit.kapila16@gmail.com>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-20T09:25:15Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Update comments to reflect changes in 8e0d32a4a1.
- 98e8fe57c24f 19 (unreleased) landed
- 214c17bd623e 18.2 landed
- a1cdb8120110 17.8 landed
-
Fix orphaned origin in shared memory after DROP SUBSCRIPTION
- 25a04aa52b52 14.21 landed
- 90d1beef62de 15.16 landed
- e22e9ab0cd45 16.12 landed
- e063ccc722e4 17.8 landed
- b07c326192d0 18.2 landed
- 8e0d32a4a1bf 19 (unreleased) landed
On Sat, Dec 20, 2025 at 3:27 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote: > > I am slightly leaning towards the idea of using a short transaction > because the tablesync worker would do things closer to the apply > workers and it would also fix the odd behavior that > pg_replication_origin_status shows NULL in the external_id column for > the origins while the COPY is being executed. But we need to verify if > it's really okay to reuse the existing origin instead of raising an > error in case where the tablesync worker retries to the data copy. > As of today, I can't think of a case where next time (restart after error) we won't generate the same origin_name but I think this will add the dependency that each time the origin name should be generated the same. Also, moving just repl_origin_create part (leaving other things like origin_advance at its location) would need some explanation in comments which is that it has some dependency on DropSubscription and cleanup. Anyway, if we want to go with creating origin in a separate transaction than COPY, then we should change few comments like: "It is possible that the origin is not yet created for tablesync worker, this can happen for the states before SUBREL_STATE_FINISHEDCOPY." in the code. -- With Regards, Amit Kapila.