On Sat, Feb 28, 2026 at 1:09 PM Andres Freund <andres@anarazel.de> wrote:
>
> I think we ought to fix it, even if it is currently harmless. It seems like
> it'd not be too hard for this to go wrong in the future, it'd e.g. make sense
> for XLogNeedsFlush() to XLogCtl->LogwrtRqst.Write and wake up walwriter. Which
> would have bad consequences if it were done with a fake LSN.
>
> I also think it might be good for XLogNeedsFlush() to have an assertion
> verifying that the LSN in the realm of the possible. It's too easy to feed it
> something entirely bogus right now and never notice.
I agree we should fix it. I noticed it while working on write
combining. I wrote the attached patch to clean up. It's more than you
were mentioning doing, but I think it makes the code nicer. You can of
course also add assertions to XLogNeedsFlush() too.
- Melanie