Re: Incorrect logic in XLogNeedsFlush()

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Incorrect logic in XLogNeedsFlush()
Date: 2025-09-12 03:15:36
Message-ID: CAFiTN-vr=3BpJJ0JmUjnoYcW5SKpOtsF0Gh+G8Kd6whOnNFAjA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 12, 2025 at 8:07 AM Dilip Kumar <dilipbalaut(at)gmail(dot)com> wrote:
>
> On Thu, Sep 11, 2025 at 4:51 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> >
> > On Wed, Sep 10, 2025 at 09:58:08AM -0700, Jeff Davis wrote:
> > > It seems like XLogFlush() and XLogNeedsFlush() should use the same
> > > test, otherwise you could always get some confusing inconsistency.
> > > Right?
> >
> > Even if the checks are duplicated (dependency could be documented as
> > well), it would make sense to me to plant a check of XLogNeedsFlush()
> > inside XLogFlush(), I think. I have not tried if some parts of the
> > tests blow up when trying to do that even after switching
> > XLogNeedsFlush() to check if WAL inserts are allowed rather than if we
> > are in recovery.
>
> +1, it really makes XLogFlush() to directly check using
> XLogNeedsFlush() after adding the "WAL inserts are allowed" check in
> XLogNeedsFlush(), this is the best way to avoid any inconsistencies in
> future as well.

I tried with the attached patch, at least check-world reports no issue.

--
Regards,
Dilip Kumar
Google

Attachment Content-Type Size
0001-Make-XLogFlush-and-XLogNeedsFlush-decision-more-cons.patch application/octet-stream 2.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2025-09-12 03:25:00 RE: Conflict detection for update_deleted in logical replication
Previous Message Dilip Kumar 2025-09-12 02:37:52 Re: Incorrect logic in XLogNeedsFlush()