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 <[email protected]> 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


Reply via email to