Re: pg_commit_ts pages can be written before WAL is flushed

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
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 13:48:36
Message-ID: awbmq0_Otwi-NujG@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"Puedes vivir sólo una vez, pero si lo haces bien, una vez es suficiente"

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message torikoshia 2026-11-25 13:53:06 Re: Why is the LSN reported for pg_logical_emit_message() different from other decoded operations?
Previous Message Jakub Wartak 2026-11-25 13:48:18 Re: passwordcheck: Make the user name check case-insensitive