Re: standby promotion can create unreadable WAL

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: "Imseih (AWS), Sami" <simseih(at)amazon(dot)com>
Cc: Dilip Kumar <dilipbalaut(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: standby promotion can create unreadable WAL
Date: 2022-08-26 16:15:27
Message-ID: CA+TgmoYC6simKPQpVDCK6p0mM6sReDfoG=GXMcSZPTnzo193BA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Aug 26, 2022 at 11:59 AM Imseih (AWS), Sami <simseih(at)amazon(dot)com> wrote:
> > I agree. Testing StandbyMode here seems bogus. I thought initially
> > that the test should perhaps be for InArchiveRecovery rather than
> > ArchiveRecoveryRequested, but I see that the code which switches to a
> > new timeline cares about ArchiveRecoveryRequested, so I think that is
> > the correct thing to test here as well.
>
> > Concretely, I propose the following patch.
>
> This patch looks similar to the change suggested in
> https://www.postgresql.org/message-id/FB0DEA0B-E14E-43A0-811F-C1AE93D00FF3%40amazon.com
> to deal with panics after promoting a standby.
>
> The difference is the patch tests !ArchiveRecoveryRequested instead
> of !StandbyModeRequested as proposed in the mentioned thread.

OK, I didn't realize this bug had been independently discovered and it
looks like I was even involved in the previous discussion. I just
totally forgot about it.

I think, however, that your fix is wrong and this one is right.
Fundamentally, the server is either in normal running, or crash
recovery, or archive recovery. Standby mode is just an optional
behavior of archive recovery, controlling whether or not we keep
retrying once the end of WAL is reached. But there's no reason why the
server should put the contrecord at a different location when recovery
ends depending on that retry behavior. The only thing that matters is
whether we're going to switch timelines.

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-08-26 16:21:36 Re: configure --with-uuid=bsd fails on NetBSD
Previous Message Tom Lane 2022-08-26 16:11:42 Re: Strip -mmacosx-version-min options from plperl build