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

Bertrand Drouvot <bertranddrouvot.pg@gmail.com>

From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Masahiko Sawada <sawada.mshk@gmail.com>
Cc: shveta malik <shveta.malik@gmail.com>, Amit Kapila <amit.kapila16@gmail.com>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2025-06-18T09:09: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.

Hi,

On Tue, Jun 10, 2025 at 02:00:55PM -0700, Masahiko Sawada wrote:
> > > > > > 0001 patch allows us to create a logical slot without WAL reservation.

Thanks for the patch and sorry to be late in this conversation.

The thing that worry me a bit with this is that that could be easy to attempt
to use the slot "by mistake" and then (as a consequence) trigger WAL reservation
by mistake on the primary. I think that this mistake is more likely to happen
with a logical slot as compared to a physical slot.

IIUC the idea is to "just" increase WAL level to 'logical' so that one could then
be allowed to make use of logical decoding from the standby. The primary goal
of logical decoding from standby is to move some load from the primay to
the standby i.e we don't expect/want the logical slot to be used on the primary.

So what about making sure that if a logical slot is created with immediately_reserve
set to false then no one can use it? (That would ensure that WAL reservation
will not happen).

That said, we might also want to create another parameter name (than
immediately_reserve) to better reflect this behavior (if we move that way).

Thoughts?

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com