pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Manu <manuelreyesbravo@gmail.com>
To: Antonin Houska <ah@cybertec.at>
Cc: shihao zhong <zhong950419@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: REPACK enhancements
Date: Wed, 11 Nov 2026 01:54:29 -0300
Message-ID: <179437286912.972010.7397230238948706686@gmail.com> (raw)
In-Reply-To: <88740.1794308080@chrudos>
References: <88740.1794308080@chrudos>

Hi Antonin,

On Tue, Nov 10, 2026 at 11:54 AM Antonin Houska <ah@cybertec.at> wrote:
> For now I commented the assertion out and added a comment on possible
> solutions.

Leaving it out looks safe to me, and the check can stay. Every other
caller passes GetCurrentTransactionId(), and in all the runs I made
(UPDATE, DELETE, savepoints, TOAST, row lockers, 150 replayed calls)
the replay reached the function with xmax still zero: the copy clears
it and only REPACK writes to the new heap. So the attached assertion
keeps the old check and states what REPACK relies on; it passes
Shihao's spec and the existing REPACK tests. With assertions off, a
REPEATABLE READ snapshot taken while REPACK waited for the lock saw the
same rows as an untouched copy of the table in every one of those runs.

A correction: in September I blamed the transient heap's XID, but that
run had failed before the final lock. Shihao has it right.

Regards,
Manu

Attachments:

nocfbot-xmax-invalid-assert.diff.txt (text/plain, 1.1K) download diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 19be1a3995b..9086b79bc0c 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -5578,12 +5578,14 @@ compute_new_xmax_infomask(TransactionId xmax, uint16 old_infomask, new_infomask2; /* - * TODO Move this statement to callers? REPACK (CONCURRENTLY) uses - * add_to_xmax different from the current transaction when replaying data - * changes. Alternatively, we can add a boolean argument to the function - * indicating the special case, but that does not look nice. - */ - //Assert(TransactionIdIsCurrentTransactionId(add_to_xmax)); + * REPACK (CONCURRENTLY) replays data changes with the XID of the + * transaction that made them (TABLE_REUSE_XID), so add_to_xmax need not + * be ours. It only replays them on tuples of the new heap that nobody + * else can lock or modify and whose xmax it has not set, so xmax is + * still invalid here and our own transaction does not matter below. + */ + Assert(TransactionIdIsCurrentTransactionId(add_to_xmax) || + !TransactionIdIsValid(xmax)); l5: new_infomask = 0;

view thread (21+ messages)  latest in thread

Message-ID: <179437286912.972010.7397230238948706686@gmail.com>
Permalink:  ../179437286912.972010.7397230238948706686@gmail.com/
Also on:    postgresql.org/message-id/179437286912.972010.7397230238948706686@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: manuelreyesbravo@gmail.com, ah@cybertec.at, zhong950419@gmail.com
  Subject: Re: REPACK enhancements
  In-Reply-To: <179437286912.972010.7397230238948706686@gmail.com>
  References: <88740.1794308080@chrudos> <179437286912.972010.7397230238948706686@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox