| From: | shveta malik <shveta(dot)malik(at)gmail(dot)com> |
|---|---|
| To: | Hüseyin Demir <huseyin(dot)d3r(at)gmail(dot)com> |
| Cc: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, shveta malik <shvetamalik(at)gmail(dot)com> |
| Subject: | Re: [PATCH] Report changes discarded for relations not in the subscription |
| Date: | 2026-11-24 08:52:24 |
| Message-ID: | CAJpy0uCFZHW_L1517tBDAPpX4BzovbV8jepC5APZNpnWu3F_yg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, Oct 30, 2026 at 1:07 PM Hüseyin Demir <huseyin(dot)d3r(at)gmail(dot)com> wrote:
>
> Hi Hayato,
>
> > > Dear Hüseyin,
> > >
> > > > I encountered an issue after a pg_upgrade of a subscriber instance.
> > > > pg_subscription_rel came back empty, and the apply worker then discarded
> > > > every incoming change while the replication origin and the publisher
> > > > slot's confirmed_flush_lsn advanced past the discarded rows. Both ends
> > > > durably recording the transactions as applied, with nothing in either log
> > > > to say otherwise.
> > >
> > > To confirm, what was the datasabse version of old and new cluster? 9a17be1e2
> > > allowed to migrate the content of pg_subscription_rel catalog[1]. It means it's
> > > unexpected behavior and must be fixed if old one is PG17+.
> > >
> > > [1]: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=9a17be1e2
> > >
> > > Best regards,
> > > Hayato Kuroda
> > > FUJITSU LIMITED
>
> Created a v2 patch and let me summarize the problem.
>
> If a table is added to a publication (ALTER PUBLICATION ... ADD TABLE)
> and ALTER SUBSCRIPTION ... REFRESH PUBLICATION is not run on the
> subscriber, the table has no pg_subscription_rel row. The apply
> worker drops every change for it in should_apply_changes_for_rel(),
> with no log message, no conflict and no statistics counter. The
> publisher is told the changes were applied, so the origin and the slot
> move past them. Rows only reappear if the table is later added and
> copied again.
>
> Report the skip from should_apply_changes_for_rel():
+1 on the proposal. The problem seems real to me.
I think the most common real-world trigger is probably FOR ALL TABLES
and FOR TABLES IN SCHEMA publications. With those, every new table on
the publisher is published automatically, and the subscriber discards
its rows until someone refreshes. A once-per-relation LOG seems like a
cheap and reasonable fix to me. I will review the patch soon.
> - relation not in the subscription: LOG, with a hint to run ALTER
> SUBSCRIPTION ... REFRESH PUBLICATION
> - relation not yet synchronized: DEBUG2
>
> Each relation is reported once per sync state for the lifetime of the
> apply worker, tracked in LogicalRepRelMapEntry, since this gate is
> reached once per change. A restarted worker reports again.
>
> Example:
> LOG: skipping changes for relation "public.tab_4" in subscription "tap_sub"
> DETAIL: The relation is not part of the subscription.
> HINT: Use ALTER SUBSCRIPTION ... REFRESH PUBLICATION to add it.
> No behavior change beyond the new messages. The patch includes TAP
> tests for the apply worker (024_add_drop_pub.pl) and for a parallel
> apply worker (015_stream.pl). I intend this for master only.
>
>
> Regards,
> Demir.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ewan Young | 2026-11-24 08:54:33 | [PATCH] btree_gist: overflow in gbt_numeric_penalty (sibling of 15b3dc140d9) |
| Previous Message | Andrei Lepikhov | 2026-11-24 08:45:39 | Re: Show 'Rows Removed by Filter' with two fractional digits in EXPLAIN |