From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
---|---|
To: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Fix assert failure when decoding XLOG_PARAMETER_CHANGE on primary |
Date: | 2025-02-04 20:35:37 |
Message-ID: | CAD21AoAzVyFBWBguF-9Z8C3A6sr_uaS5RQ3tBUC0PsCp-mFtpQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Feb 4, 2025 at 10:20 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> On Tue, Feb 4, 2025 at 12:59 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> >
> > On Sun, Feb 2, 2025 at 8:11 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> > >
> > > On Fri, Jan 24, 2025 at 4:05 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> > > >
> > > > When a standby replays a XLOG_PARAMETER_CHANGE record that lowers
> > > > wal_level from logical, we invalidate all logical slots only when the
> > > > standby is in hot standby mode:
> > > >
> > > > if (InRecovery && InHotStandby &&
> > > > xlrec.wal_level < WAL_LEVEL_LOGICAL &&
> > > > wal_level >= WAL_LEVEL_LOGICAL)
> > > > InvalidateObsoleteReplicationSlots(RS_INVAL_WAL_LEVEL,
> > > > 0, InvalidOid,
> > > > InvalidTransactionId);
> > > >
> > > > However, it's possible that this record is replayed when not in hot
> > > > standby mode and the slot is used after the promotion. In this case,
> > > > the following Assert in xlog_decode() fails:
> > > >
> > > > /*
> > > > * This can occur only on a standby, as a primary would
> > > > * not allow to restart after changing wal_level < logical
> > > > * if there is pre-existing logical slot.
> > > > */
> > >
> > > Shouldn't we do similar to what this comment indicates on standby? We
> > > can disallow to start the server as standby, if the hot_standby is off
> > > and there is a pre-existing logical slot.
> >
> > It seems like a better idea. I thought we could pass StandbyMode to
> > StartupReplicationSlots() and check if there is a pre-existing logical
> > slot, but it would break the ABI compatibility. It might not be a
> > problem in practice as StartupReplicationSlots() is normally used only
> > by the startup process. But if we want to avoid that we can introduce
> > a new function for that.
>
> Since StandbyMode is exposed, we don't need to change the function
> signature. I'll update and submit the patch soon.
>
I've attached the updated patch. The fix needs to be back-patched to
v16 where logical decoding on standby was introduced.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Fix-assertion-when-decoding-XLOG_PARAMETER_CHANGE.patch | application/octet-stream | 4.8 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2025-02-04 20:45:13 | Re: Add -k/--link option to pg_combinebackup |
Previous Message | Andrew Dunstan | 2025-02-04 20:34:36 | Re: RFC: Additional Directory for Extensions |