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: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>, shveta malik <shveta.malik@gmail.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-10-27T19:24:12Z
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 Sun, Oct 26, 2025 at 11:49 PM Hayato Kuroda (Fujitsu)
<kuroda.hayato@fujitsu.com> wrote:
>
> Dear Sawada-san,
>
> > > Why can't we avoid counting invalid slots? I think this needs more
> > > comments. BTW, shouldn't this patch consider changing
> > > effective_wal_level when the last logical slot is invalidated?
> > > Ideally, when logical decoding is not possible in the system, then we
> > > can reduce the wal_level back to replica, no?
> >
> > Hmm, good point. I've considered this idea before but I didn't
> > implement it probably because it makes the code more complex. But
> > thinking of this idare carefully, it doesn't seem too complex. I've
> > implemented this part as a separate patch to make reviews easy. I'll
> > merge them if it looks good.
>
> I confirmed and 0002 looks basically good. One minor comment:
>
> ```
> # Drop the invalidated slot, decreasing effective_wal_level to 'replica'.
> $standby4->safe_psql('postgres',
>         qq[select pg_drop_replication_slot('standby4_slot')]);
> wait_for_logical_decoding_disabled($standby4);
> test_wal_level($standby4, "replica|replica",
>         "effective_wal_level doesn't change after dropping the last invalidated slot"
> );
> ```
>
> Not sure the part is needed. Previous test has already ensured that
> effective_wal_level would be replica. It might be trivial that dropping the slot
> would keep the state.

Fair point. Removed.

Regards,

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