Re: Incorrect logic in XLogNeedsFlush() - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Incorrect logic in XLogNeedsFlush()
Date
Msg-id aNT0-c1T_oX0iRTQ@paquier.xyz
Whole thread Raw
In response to Re: Incorrect logic in XLogNeedsFlush()  (Melanie Plageman <melanieplageman@gmail.com>)
List pgsql-hackers
On Wed, Sep 24, 2025 at 05:33:08PM -0400, Melanie Plageman wrote:
> I think he's referring to the order of checks inside
> UpdateMinRecoveryPoint(). Something like the attached patch.

Yep, thanks.  What you are doing with XLogNeedsFlush() looks correct.

> And, if I'm not mistaken, there was another idea mentioned in [1]
> which was to move to using GetRecoveryState() in XLogNeedsFlush() and
> UpdateMinRecoveryPoint instead of relying on the variable InRecovery +
> XLogRecPtrIsInvalid(LocalMinRecoveryPoint) to distinguish crash
> recovery.

The removal of InRecovery means that we would disable a bit more
aggressively updateMinRecoveryPoint for other processes than the
startup process as InRecovery is only set in the startup process,
which should be OK.  Some comments of XLogNeedsFlush(), like the
comment block on top of the new GetRecoveryState() call, would need a
refresh.

XLogNeedsFlush() has a bit further down your change a path where
updateMinRecoveryPoint is set to false for other processes than the
startup process.  A shortcut based on GetRecoveryState() should make
its removal possible, simplifying a bit more the code.

> These should probably be in the same commit. I think that if what I
> have is correct, it is a clarity improvement.

I'd rather tackle each thing separately.  We're changing slightly
different things here: depending on GetRecoveryState() is one thing a
bit more invasive than the second thing, which is to switch the order
of the checks of updateMinRecoveryPoint.  Perhaps I'm the only one
picky here as the lines are thin, though :o)
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Fix incorrect function comment of stringToNodeInternal
Next
From: Richard Guo
Date:
Subject: Re: Inconsistent Behavior of GROUP BY ROLLUP in v17 vs master