Re: [PATCH] Report changes discarded for relations not in the subscription

From: Peter Smith <smithpb2250(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>
Subject: Re: [PATCH] Report changes discarded for relations not in the subscription
Date: 2026-11-23 05:55:34
Message-ID: CAHut+PtoEOCaN_CmTACkiJg=bCfyC4WjF2O4m9c1u_YRW-XCcA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Some review comments for patch v3.

======
src/backend/replication/logical/worker.c

1.
+ /*
+ * This is reached once per change, so remember the last state reported in
+ * the relation map entry and stay quiet until the state changes.
+ */
+ if (rel->state == rel->last_unapplied_state)
+ return;

Comment seems overly verbose. How about just something like :

/* Quick return if no state change. */

======
src/test/subscription/t/024_add_drop_pub.pl

2.
I'm not sure why 2 test tables (`tab_4` and `tab_5`) are needed. Isn't
one enough?

~

3.
It's a bit overkill to insert 100+ rows to test this. Maybe do less
work to make tests more efficient.

======

On Mon, Nov 23, 2026 at 2:08 AM Hüseyin Demir <huseyin(dot)d3r(at)gmail(dot)com> wrote:
>
...
> >
> > 4B.
> > IIUC, you could achieve the same with a single member "char
> > last_unapplied_state" with an initial value of '?'.
> >
> > #define SUBREL_STATE_INIT_LAST_UNAPPLIED '?'
>
> Yes, that works and is simpler. v3 replaces reported and reportedstate
> with a single last_unapplied_state, and report_unapplied_change() now
> just checks rel->state == rel->last_unapplied_state.
>
> The relation map entries are zeroed with memset() when they are built,
> and a zero here is SUBREL_STATE_UNKNOWN. That is exactly the state
> that gets the LOG message, so a zeroed field would wrongly suppress
> it. v3 therefore sets the sentinel explicitly after the memset() in
> both logicalrep_relmap_update() and logicalrep_partition_open(), and
> the field's comment says so. I used your
> SUBREL_STATE_INIT_LAST_UNAPPLIED name and defined it in
> logicalrelation.h, next to the struct that uses it.
>

OK, that's like what I meant. Although I am not sure if
SUBREL_STATE_INIT_LAST_UNAPPLIED would be better defined adjacent to
all the other non-stored SUBREL_XXX.

Meanwhile, I won't review this patch further until more people review
it and agree that this state-based logging is the best strategy.

======
Kind Regards,
Peter Smith.
Fujitsu Australia

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sho Ito 2026-11-23 05:58:24 Re: [PATCH] psql: Fix REPACK index completion after a column list
Previous Message Peter Smith 2026-11-23 05:18:49 Re: Initial table sync copies the whole table when it is no longer published