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

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: 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-10-27 12:42:30
Message-ID: CAA4eK1KvGHp=DjbrqZFwRJZRhr6M+W-pWpxLb=f-Q1uSFMoT9g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Oct 25, 2025 at 4:06 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> On Fri, Oct 24, 2025 at 4:48 AM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> >
> > 5.
> > +bool
> > +CheckLogicalSlotExists(void)
> > {
> > …
> > + /* NB: counting invalidated slots */
> > +
> > + if (SlotIsLogical(s))
> >
> > 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.
>

Thanks for looking into it. I didn't get a chance to review the entire
0002 but I looked at InvalidateObsoleteReplicationSlots() and have a
few questions related to that.

In InvalidateObsoleteReplicationSlots(), the patch increments
n_valid_logicalslots before trying to invalidate the slot. Say, if
there is just one logical slot which got invalidated, then because we
have first incremented n_valid_logicalslots, how will it request to
disable logical_decoding after invalidating the last logical slot?

Another related point is that, say we decide to disable decoding
because the last logical slot got invalidated and
RequestDisableLogicalDecoding()->LogicalDecodingStatusChangeAllowed()
returns false, then how the disabling will happen?

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2025-10-27 13:10:07 Re: NLS: use gettext() to translate system error messages
Previous Message Alena Vinter 2025-10-27 12:22:12 Re: Resetting recovery target parameters in pg_createsubscriber