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

Masahiko Sawada <sawada.mshk@gmail.com>

From: Masahiko Sawada <sawada.mshk@gmail.com>
To: shveta malik <shveta.malik@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>, Peter Smith <smithpb2250@gmail.com>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, Shlok Kyal <shlok.kyal.oss@gmail.com>, Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-12-01T05:59:05Z
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 Thu, Nov 27, 2025 at 3:51 AM shveta malik <shveta.malik@gmail.com> wrote:
>
> On Thu, Nov 27, 2025 at 2:32 AM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
> >
> >
> > I've squashed all fixup patches and attached the updated patch.
> >
>
> Thanks for test results and the patch. Please find a few comments:
>
> 1)
> If primary has effective_wal_level as logical and standby has zero
> slots; then during promotion of standby, if I try to create a slot, it
> is restricted as intended, but it gives misleading message:
> postgres=# SELECT pg_create_logical_replication_slot('slot',
> 'pgoutput', false, false, false);
> ERROR:  logical decoding on standby requires "effective_wal_level" >=
> "logical" on the primary
> HINT:  Set "wal_level" >= "logical" or create at least one logical
> slot when "wal_level" = "replica".
>
> One possibility is we extend the message as follows:
> "Logical decoding on standby requires either effective_wal_level >=
> logical on the primary or that recovery has finished." and remove
> errhint?

But the proposed message seems to contradict with its condition:

if (RecoveryInProgress() && !IsLogicalDecodingEnabled())

That is, logical decoding on standby is not necessarily enabled after
recovery has finished (e.g., when it doesn't have a valid logical
slot).

If you get the error message while the standby is being promoted,
isn't it a normal behavior given that the standby has not been fully
promoted yet?


I've addressed other points in the next version patch.

Regards,

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