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

From: shveta malik <shveta(dot)malik(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(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>, shveta malik <shveta(dot)malik(at)gmail(dot)com>
Subject: Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Date: 2025-10-10 04:02:30
Message-ID: CAJpy0uAK1DhVRQm3xufcgncF47ha5hY0AonojiWXunzZSxN-vg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 9, 2025 at 4:14 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> Thank you for the comments.
>
> I've attached the updated patch. As we discussed, it now uses the lazy
> deactivation in all cases and has the discussed points in the comments
> atop logicalctl.c.
>

Thank You for making the changes. I am in the process of verifying the
patch. Please find one concern.

When I promote a standby, there's a brief period during
recovery-completion when status_change_allowed is set to true and also
RecoveryInProgress() is still true. If I try to create a logical
replication slot on the standby during this window, it fails with the
following error:

postgres=# SELECT pg_create_logical_replication_slot('slot1',
'pgoutput', false, false, false);
ERROR: logical decoding on standby requires "effective_wal_level" >=
"logical" on the primary
HINT: To enable logical decoding, set "wal_level" >= "logical" or
create at least one logical slot when "wal_level" = "replica".

Note that the primary already has logical slots. This issue occurs
because logical decoding is disabled by
UpdateLogicalDecodingStatusEndOfRecovery() due to no existing slots on
standby while RecoveryInProgress() is still true. Should
CheckLogicalDecodingRequirements() also consider
'status_change_allowed' on standby to handle this transition more
gracefully?

thanks
Shveta

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2025-10-10 04:13:24 Re: new environment variable INITDB_LOCALE_PROVIDER
Previous Message Chao Li 2025-10-10 03:29:01 Re: speedup COPY TO for partitioned table.