Re: POC: enable logical decoding when wal_level = 'replica' without a server restart

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Date: 2025-12-01 05:50:07
Message-ID: CAD21AoBdJu1EDpmGsxCvQ7adfNkYEZoet2W+DFxiWDQG=j-k8A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 27, 2025 at 12:33 AM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> Hi Sawada-San.
>
> Some review comments for v30-0001.

Thank you for the comments!

> ======
> src/backend/replication/logical/logicalctl.c
>
> 5.
> + * In the future, we could extend support to include automatic transitions
>
> Sawada-San reply to previous "XXX" comment:
> Hmm, I've seen we use an "XXX" marker like "TODO" or "FIXME", but what
> the comment explains is not actually a todo but possible future
> enhancements.
>
> ~
>
> You can search the source code for regex “XXX.*future” to find
> multiple examples just like this.

Yes, but I can also see some examples where we don't have "XXX"
marker. So I don't see why we should add it in this patch.

> ~
>
> 6b.
> Would it be better to have a self-documenting enum {UNKNOWN, ENABLED,
> DISABLED} instead of some magic int values that need lots of comments
> explaining how to use them?

No, we should not cast enum values directly to a boolean. We have a
precedent of such usage like LocalXLogInsertAllowed, and I don't think
we can reduce the comments even if we use a self-documenting enum
since the usage is complicated. We could consider #define values 0, 1,
and -1 but it seems to be overkill to this usage.

>
> ~~~
>
> LogicalDecodingCtlShmemInit:
>
> 7.
> +void
> +LogicalDecodingCtlShmemInit(void)
> +{
> + bool found;
> +
> + LogicalDecodingCtl = ShmemInitStruct("Logical decoding control",
> + LogicalDecodingCtlShmemSize(),
> + &found);
> +
> + if (!found)
> + MemSet(LogicalDecodingCtl, 0, LogicalDecodingCtlShmemSize());
> +}
>
> Maybe assign LogicalDecodingCtlShmemSize() to some variable; no need
> to invoke it 2x.

It's actually inlined so we don't need to have an additional variable here .

> InvalidatePossiblyObsoleteSlot:
>
> 11.
> /* Let caller know */
> - *invalidated = true;
> + invalidated = true;
>
> This was a review v29 (#12) review comment that seems to have been
> missed. That comment is stale (should be removed) because
> 'invalidated' is no longer returned by reference like before.

Yes, but it doesn't change the fact that the function lets the caller
know using this variable if the slot has been invalidated, no?

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2025-12-01 05:59:05 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Previous Message Corey Huinker 2025-12-01 05:41:37 Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions