Re: pg_commit_ts pages can be written before WAL is flushed

From: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Jeff Davis <pgsql(at)j-davis(dot)com>
Subject: Re: pg_commit_ts pages can be written before WAL is flushed
Date: 2026-11-25 14:39:49
Message-ID: CAJTYsWV27qez86=N15o9NRjegNaWN3gb_ECt7ss4QYHmqSxMsQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, 25 Nov 2026 at 19:18, Álvaro Herrera <alvherre(at)kurilemu(dot)de> wrote:
>
> Hello
>
> On 2026-Nov-25, Ayush Tiwari wrote:
>
> > While re-testing Jeff's patch [1], I found a similar issue with
> > pg_commit_ts. After a crash, the row I had inserted was gone and
> > pg_xact_status() said aborted, which is fine for an async commit, but
> > pg_xact_commit_timestamp() still returned its commit timestamp
> > instead of NULL.
>
> Hmm, I vaguely recall that the reason for this is that it's not supposed
> to matter. pg_clog is the authoritative source to indicate whether a
> transaction committed; if you inquire for the commit timestamp of a
> transaction that didn't commit, it's your fault. When the transaction
> commits again (I mean, the next time a transaction gets the same Xid
> value), the commit_ts record would be updated to the new value, so
> there's no harm.
>
> I'm not opposed to consider this change in master, but unless there's a
> reason to think that this is a problem in practice, I wouldn't bother
> backpatching.

Yeah, that makes sense. I'd expected NULL for an aborted xid, but I
don't have a case where this causes trouble in practice. If the change
seems worth doing, I'm happy to keep it to master.

Regards,
Ayush

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-11-25 14:44:40 Re: Wrong table in "conflicting or redundant WHERE clauses / column lists" publicaiton error
Previous Message Ayoub Kazar 2026-11-25 14:32:04 Re: Remove inner joins based on foreign keys