Re: Possible crash on standby

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Possible crash on standby
Date: 2022-09-09 17:18:35
Message-ID: 20220909171835.GA2255629@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 09, 2022 at 05:29:49PM +0900, Kyotaro Horiguchi wrote:
> This is because WaitForWALToBecomeAvailable doesn't call
> XLogSHutdownWalRcv() when walreceiver has been stopped before we reach
> the WalRcvStreaming() call cited above. But we need to set
> InstasllXLogFileSegmentActive to false even in that case, since no one
> other than startup process does that.

Nice find.

> Unconditionally calling XLogShutdownWalRcv() fixes it. I feel we might
> need to correct the dependencies between the flag and walreceiver
> state, but it not mandatory because XLogShutdownWalRcv() is designed
> so that it can be called even after walreceiver is stopped. I don't
> have a clear memory about why we do that at the time, though, but
> recovery check runs successfully with this.

I suppose the alternative would be to set InstallXLogFileSegmentActive to
false in an 'else' block, but that doesn't seem necessary if
XLogShutdownWalRcv() is safe to call unconditionally. So, unless there is
a bigger problem that I'm not seeing, +1 for your patch.

--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2022-09-09 17:19:14 Re: Error "initial slot snapshot too large" in create replication slot
Previous Message Tom Lane 2022-09-09 17:16:16 Re: is_superuser is not documented