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

Amit Kapila <amit.kapila16@gmail.com>

From: Amit Kapila <amit.kapila16@gmail.com>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: Shlok Kyal <shlok.kyal.oss@gmail.com>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, shveta malik <shveta.malik@gmail.com>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-09-11T04:49:34Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix regression test failure when wal_level is set to minimal.

  2. Toggle logical decoding dynamically based on logical slot presence.

  3. Disallow server start with sync_replication_slots = on and wal_level < logical.

On Wed, Sep 10, 2025 at 12:15 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
>
> I've reread his report. IIUC what happened in his test scenario was;
> while he was restarting the primary server (to make
> wal_level='replica' effect), the slotsync worker exited due to a
> connection error. Then after the primary started up, with the patch,
> the slotsync worker was not launched again, whereas it was launched
> again without the patch. This is because with the patch, the standby
> disables the logical decoding when replaying the STATUS_CHANGE record.
> If the primary enables logical decoding again, the STATUS_CHANGE
> record with logical_decoding=true is replicated to the standby and it
> launches the slotsync worker again. That is, the slotsync worker
> launches based on the standby's effective_wal_level. On the other
> hand, before the patch, the slotsync worker is launched solely based
> on the standby's wal_level. Therefore, it launches but doesn't do
> anything in this case (as the primary should not have any logical
> slot). I thought it makes sense that we don't launch the slotsync
> worker when effective_wal_level is 'replica', but is your suggestion
> that the slotsync worker needs to be launched only when the standby's
> wal_level is logical regardless of effective_wal_level?
>

No, the patch's behavior is good. I was thinking whether we can change
it even for HEAD and then the patch's behavior will match with HEAD.
But I think that may not be as straight-forward because standby may
not have that information readily available. Anyway, if there is no
simple way to change HEAD's behavior then we can leave that as it is.

-- 
With Regards,
Amit Kapila.