| From: | Hüseyin Demir <huseyin(dot)d3r(at)gmail(dot)com> |
|---|---|
| To: | shveta malik <shveta(dot)malik(at)gmail(dot)com> |
| Cc: | Peter Smith <smithpb2250(at)gmail(dot)com>, "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-12-04 15:14:17 |
| Message-ID: | CAB5wL7aRiztZv6bTDYxwDz6uqncP7BmJ6L0m4=E89mUW8CRLZQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
Thanks for the review.
> 1)
> Should this be written as below, so that translators don't translate
> the SQL command text?
Agreed, I will change it in v8.
> 2)
> How about moving it to logicalrelation.h, next to
> last_unapplied_state?
Agreed. I had moved it to pg_subscription_rel.h in v4 to keep it with
the other non-stored states, but I missed that it then ends up in
pg_subscription_rel_d.h.
> 3)
> If a table is renamed on the publisher, and a table with the new name
> already exists on the subscriber but is not part of the subscription,
> the subsequent discarded changes are not reported
I can reproduce this on v7. The same happens with ALTER SCHEMA ...
RENAME. I think it is worth fixing, because the log then only mentions
the old name while changes for the new one are discarded silently. I
tried your suggestion of carrying over last_unapplied_state only when
nspname and relname match, and the new name is then reported. Streamed
transactions
and CREATE INDEX still do not repeat the message.
The only downside my LLM found is one duplicate message when a
streamed transaction that renames the table is rolled
back. The leader also processes the RELATION messages of that
transaction, so the old name is reported once more afterwards. That
seems reasonable to me. Covering this rare case is a better choice.
If there are no objections, I will include this in v8.
Regards,
Demir.
shveta malik <shveta(dot)malik(at)gmail(dot)com>, 4 Ara 2026 Cum, 07:00 tarihinde
şunu yazdı:
>
> On Thu, Dec 3, 2026 at 10:43 AM Hüseyin Demir <huseyin(dot)d3r(at)gmail(dot)com> wrote:
> >
> > Thanks for the review. All three points are addressed in the attached v7.
> >
> > > 1.
> > > #define SUBREL_STATE_INIT_LAST_UNAPPLIED '?'
> >
> > Agreed, the similarity to SUBREL_STATE_INIT is misleading. Renamed to
> > SUBREL_STATE_LAST_UNAPPLIED_NONE.
> >
> > > 2.
> > > ... the placement of this new field has split `state` and `statelsn`
> > > ... Suggests putting your new field last.
> >
> > Done. last_unapplied_state is now the last field of
> > LogicalRepRelMapEntry, so state and statelsn are together again under
> > their "Sync state." comment.
> >
> > > 3.
> > > ... other wait_for_log(...) are not wrapped in ok(), so the
> > > ones in this patch didn't need to be either.
> >
> > Right. wait_for_log() dies on timeout rather than returning false, so
> > the ok() did not add anything, and no other test wraps it. v7 calls
> > wait_for_log() directly in both 024_add_drop_pub.pl and 015_stream.pl,
> > still with the combined LOG and DETAIL regex. There are no behaviour
> > changes. 024_add_drop_pub and 015_stream pass.
> >
>
> Thanks for taking care of my earlier comments. A few trivial things:
>
> 1)
> + errhint("If this relation should be replicated, use ALTER
> SUBSCRIPTION ... REFRESH PUBLICATION."));
>
> Should this be written as below, so that translators don't translate
> the SQL command text?
>
> errhint("If this relation should be replicated, use %s.",
> "ALTER SUBSCRIPTION ... REFRESH PUBLICATION")
>
> 2)
> SUBREL_STATE_LAST_UNAPPLIED_NONE is defined under
> EXPOSE_TO_CLIENT_CODE in pg_subscription_rel.h, so genbki.pl copies it
> into pg_subscription_rel_d.h, which is meant for values frontend code
> may need. It is not a catalog state and is only used by the apply
> worker. How about moving it to logicalrelation.h, next to
> last_unapplied_state?
>
> 3)
> If a table is renamed on the publisher, and a table with the new name
> already exists on the subscriber but is not part of the subscription,
> the subsequent discarded changes are not reported, because
> last_unapplied_state is carried over from the old entry. This is a
> minor case, so it's up to you whether to handle it. A possible fix is
> to carry over last_unapplied_state only when nspname and relname in
> the new RELATION message match the old entry. But again, I would like
> to see what you and others think before we fix this.
>
> thanks
> Shveta
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nathan Bossart | 2026-12-04 15:54:07 | Re: add --transfer-mode to pg_upgrade |
| Previous Message | Ashutosh Bapat | 2026-12-04 14:57:47 | Re: Better shared data structure management and resizable shared data structures |