Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR8Ld-00000000iAF-1Vih for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Nov 2026 13:26:45 +0000 Received: from localhost ([127.0.0.1]:55652 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xR8La-0000000B7wC-3MtK for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Nov 2026 13:26:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:45006) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR8La-0000000B7w1-1wJn for pgsql-hackers@lists.postgresql.org; Wed, 11 Nov 2026 13:26:42 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xR8LY-00000000T8G-0klc for pgsql-hackers@lists.postgresql.org; Wed, 11 Nov 2026 13:26:42 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4a1b07c3c5fso30415375e9.1 for ; Wed, 11 Nov 2026 05:26:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1794403599; x=1795008399; darn=lists.postgresql.org; h=message-id:date:content-transfer-encoding:content-id:content-type :mime-version:comments:references:in-reply-to:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to:content-type; bh=kAQPwEN2sb8BslyyCBfP7jEAU0qkReXNPlxS7pX9oGk=; b=kY9Tq14LlbxUy5xHzJdRb5s7+BOo7WYfRr9l/xvOFjWGVhGoBPB6VnJuPb9/1tr5kZ JJfV4zuoeekBI2Hnj8dirmcrbpZuc3iquqOgi+IzHuKUnOQsAKLnLHL7Ky/DE5ZXKh6f oyxojv5kcUS2R8gjTEx8bg+jQBmwSpAKPE7eXVlGKyCuEywGde+zDp/nPr0acJ0BCuFf 6qgv2VwKxJs59iaC/8lUh+GvL0gMBwSWOQIfpfRFw9cVQ0NMKs5gzOZjIzHQA4oFBQUe XvMSAxd4Q/kXbzEFznFQjR5E9htl+s/gjKYOMRHXxjURHSb6kZ9iAYdMqN9eiOs8L0rt zPug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794403599; x=1795008399; h=message-id:date:content-transfer-encoding:content-id:content-type :mime-version:comments:references:in-reply-to:subject:cc:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=kAQPwEN2sb8BslyyCBfP7jEAU0qkReXNPlxS7pX9oGk=; b=hIeicLyWdHJ2LkhfVtu74yV3ctH+qVZPJqb6H9mVTzE4HC8PZ0KdBGKR9F0ii9fC7N rMAJ9p54ZDu75gdfUUcCo14RMgIqq5EFHFFheRxMN7AvY74nmq6heLBx9a/oAiOZ4IlU 46N4F14Nytwpkf8Q/dHYEjlS7EuI2FgQRjh8Qc+8QAPK28q33m5StOZCBZITUmaCXDZg nOair30rBhtcEbL7ap7rcuJABZ4ZXu5uyRpNhVGWN8KxdjmxP31iXAD/xyedmJHDYZlY ICiEvwmL6ijwpHgAUAcY0SQPOON9L7pKURQ0wzLz5AOXCU0CwZco1mSOTxboKx0Owy6E yYMQ== X-Forwarded-Encrypted: i=1; AL+hErE1/827nEM8MLWRy89iMcw8/7zQpIcqUuFt5DYOitZ6huEbtEUHMSCK4MjCoBPiHtxmWuThTWWXnQIu1J9e@lists.postgresql.org X-Gm-Message-State: APuU4Z8w55zN/v+YbP0MVP2gfeUF+PP3HvwYpdob8kCzyKnq9+wYVexA Bm9t1PzYcyYrCt8wJwvJw+Qlia8fpbNPd1mVgwrnqxc2m7NSHwmgoYqW1BLoIytPHG0= X-Gm-Gg: AYBFou1l8py/efKQZAdFrrEjjcnLVOa+XObE+OlLnrRjQnT5KeSzscFm7p051uG6xZF XLDTd8YPQO+vCg66A4tLgozyZFR0TX+jx/BG8Egy7N4R5OvRCWCvsWMAzVp8UUNIZCn2Zxj+uNO lJdhD2VNNji9QhxHuhVQtIk4NaXMZ//B7qVC9t+wrdANpNNm5gU9Enk8WxT9brFyvkbXHuH35ZJ JvPejxhkj/md1C+t+TaZ5HfF1bF4hS4RLtnnSXKiY/b8//lTt80VMPInk7dh8VSuwjM8FXmit2f 53l/kJ+NXocMWKcrr1bTpnjXpazomoWKNSbjPbXoeQd9UHYSrR68S9uajhKlckjMZeBYxTuLF9w K3tIGIhr0+1R2ixtPcs+pu+wjdtVGHNmDTzz3MACTq2GyR1WnHFsSd/3MpAHvOZTevYje3jvDAW BL/DbXzlkY9rCiHpMIcgp+Ojwzh9fN6Jefywk2SID5YizpQUOO3+BbIzmnaIhlMYZ3sAH0pqo0B oextj5pV3uq53SfW+y4qELufdJqUkRZR0dMTyMt+jxq5Of8enhQimJplvljwrH3E1kOGVaNq40m CdZ6ICKfBzKBtvfzJDOV4PPoLF6Fp4TYlGceysSE X-Received: by 2002:a05:600c:3b98:b0:4a6:7d6:821f with SMTP id 5b1f17b1804b1-4ba0938a529mr48041345e9.29.1794403599271; Wed, 11 Nov 2026 05:26:39 -0800 (PST) Received: from chrudos (109-81-170-200.rct.o2.cz. [109.81.170.200]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4ba01fef1d0sm136972655e9.13.2026.11.11.05.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2026 05:26:38 -0800 (PST) From: Antonin Houska To: Manu cc: shihao zhong , pgsql-hackers@lists.postgresql.org Subject: Re: REPACK enhancements In-reply-to: <179437286912.972010.7397230238948706686@gmail.com> References: <88740.1794308080@chrudos> <179437286912.972010.7397230238948706686@gmail.com> Comments: In-reply-to Manu message dated "Wed, 11 Nov 2026 01:54:29 -0300." X-Mailer: MH-E 8.6+git; nmh 1.8; Emacs 31.1.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <309061.1794403598.1@chrudos> Content-Transfer-Encoding: quoted-printable Date: Wed, 11 Nov 2026 14:26:38 +0100 Message-ID: <309062.1794403598@chrudos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Manu wrote: > Hi Antonin, > = > On Tue, Nov 10, 2026 at 11:54 AM Antonin Houska 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; ... > 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, ui= nt16 old_infomask, > new_infomask2; > = > /* > - * TODO Move this statement to callers? REPACK (CONCURRENTLY) uses > - * add_to_xmax different from the current transaction when replaying d= ata > - * changes. Alternatively, we can add a boolean argument to the functi= on > - * 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 n= ot > + * be ours. It only replays them on tuples of the new heap that nobod= y > + * 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)); > = I don't really understand why 'xmax' should be involved. The original assertion checks exactly whether 'add_to_max' is the "current transaction"= and I tried to disable it exactly when the function is called by REPACK (to re= play data changes). However, 'xmax' can be invalid even in cases unrelated to REPACK (i.e. when doing "regular" UPDATE / DELETE). Thus what you propose makes the assertion a bit less useful. -- = Antonin Houska Web: https://www.cybertec-postgresql.com