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.94.2) (envelope-from ) id 1uqath-009EXD-5p for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 17:22:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uqatg-00C2Tw-Kc for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 17:22:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uqatg-00C2Tn-9x for pgsql-hackers@lists.postgresql.org; Mon, 25 Aug 2025 17:22:20 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uqate-001nZB-1U for pgsql-hackers@lists.postgresql.org; Mon, 25 Aug 2025 17:22:20 +0000 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-afcb78da8a7so734296766b.1 for ; Mon, 25 Aug 2025 10:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1756142535; x=1756747335; darn=lists.postgresql.org; h=message-id:date:content-transfer-encoding:content-id:mime-version :comments:references:in-reply-to:subject:cc:to:from:from:to:cc :subject:date:message-id:reply-to; bh=Hj2QYxYwn1MirgNcBX4AVM3rMICyIxT603/W/pQL5pQ=; b=lvAWfzQrW+jsuQsX6+vnPt9YNZ3RGfSRg42NP2uVuEp1F4NlM4RnAFeCwzZuvmL72y aRRNsa6rsN/8dLcletplvc1+ZeC2cmwQGHRpNgxoaDH1vdUlSbL/s+IMnr7sTLEqRHxt CjE+JU3gu75Jef15hesXtmC6AotGhyHNxO+BU0K2nV5rlGFGS1J8jeLgmMQz3j7YhZNM WutbLw2pQrO52G7cyeUYFMyLhlDmaGWqbfvqCvD9AoKywDH7vjRSjN9ToYdE0+hrH/Kb j96LkN7EJUkMz6L2Rg4xFTvEfS49J4LWPISHPQYYvEz3i/FQp9vfD7RaMBxmL1Gj7yR9 Xs/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756142535; x=1756747335; h=message-id:date:content-transfer-encoding:content-id:mime-version :comments:references:in-reply-to:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Hj2QYxYwn1MirgNcBX4AVM3rMICyIxT603/W/pQL5pQ=; b=UHgb391pPMyiTPDErWO/0+9/VaH0IScXuYLXTylHX48+/CYFOnemq0Bpwxl7HH5vRL N5aCv+xsMEXBqwGq/coxh+AfxXDLZyyYcfTHqu1EIETnjLArov8Yd6tnFNyKws7UI31P n9Dio/JKgHt0DOdbVvxus9W1sT4JdaMDM/XmFsr6ZJviSQ59/a5JkFH9Y9il6r1T4p/j bEL+Ti7dBVzHdGKq7LRXUI0Tg+jJnrZACeYzAObXKPrclC6dGYLo291q2ZIFZ/meJ11i WaMA0xPWajLKlceYcCTyWS3BjMB8jZkgusz8I97TMgHLsWtBoLG4280c6sfadGZ88L9+ X/Cg== X-Forwarded-Encrypted: i=1; AJvYcCVvssePhiJMOiubMhs/Pz89RT5AA2S3qZZXiNGEHpjTy80PLPj+YK4AE4CdqMLZ6C6gQxkC35Jw2MrClGCz@lists.postgresql.org X-Gm-Message-State: AOJu0Ywx573OW1J9yyDBee0Jyp8xUZBWkyb4TTm/xutfvCse0uNg9XxH AUXx7L1G1fT84QoOstdfRJcjINq7KJG87QJepUfYCI+g3JxjhKkg1uXTKdwXl2j3ddQ= X-Gm-Gg: ASbGnct47L5KKDqaeyfPo7IaHrbz3Em+Ks0218bRMhOiLlGWmFCO6WuYkmbuhWLk/EI j91596wagZuRwOjUl9B9NFtMjdwoxJ3JD8z53VDYozRukq0a11XCIeZi6hdxMcHsH4bm1P07oJA ZWxCODTFQXEnNLUd7dFPRyBuAWiFdrMg4KXFx0KRM/RinLv6eD49tfYxHFjKU6AaudR1ck2b6zt hEY+8ikklZV67FQmivwLauPWwvwa9TKwMfsJfMPm68CMCElVYOTqz3ECoYKLbQLPnA/T3I4GVvi TYCToVFSbjBp4kAYo09NsCd+e4zpCiEJ8n6v6O/b9/K2Nf+hRoenq83cio2htQ31Zi2TABhtd2S 3iHPG+RzIzja7zUxBiyCQIwV4B83hmldh5+GQ X-Google-Smtp-Source: AGHT+IG8DigFXO4r0SYRNCr9yXtvIPIjO+FEmDgCPXhFtvgdFYPyw628MG6ZMixMCYXulv5A2UtMMA== X-Received: by 2002:a17:907:1b29:b0:afa:1b3f:37a2 with SMTP id a640c23a62f3a-afe295d2b84mr1223550966b.37.1756142534961; Mon, 25 Aug 2025 10:22:14 -0700 (PDT) Received: from localhost (109-81-168-144.rct.o2.cz. [109.81.168.144]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-afe8725112bsm182509966b.36.2025.08.25.10.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Aug 2025 10:22:14 -0700 (PDT) From: Antonin Houska To: Mihail Nikalayeu cc: Alvaro Herrera , Fujii Masao , Robert Treat , Pg Hackers Subject: Re: Adding REPACK [concurrently] In-reply-to: References: <202508091333.qvgvo7ikuezm@alvherre.pgsql> <40729.1755799624@localhost> <9536.1756127358@localhost> <21931.1756136535@localhost> Comments: In-reply-to Mihail Nikalayeu message dated "Mon, 25 Aug 2025 18:23:09 +0200." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <24482.1756142534.1@localhost> Content-Transfer-Encoding: quoted-printable Date: Mon, 25 Aug 2025 19:22:14 +0200 Message-ID: <24483.1756142534@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Mihail Nikalayeu wrote: > Hi, Antonin > = > > How does HeapTupleSatisfiesSelf() recognize the status of any XID w/o = using a > > snapshot? Do you mean by checking the commit log (TransactionIdDidComm= it) ? > = > Yes, TransactionIdDidCommit. I think the problem is that HeapTupleSatisfiesSelf() uses TransactionIdIsInProgress() instead of checking the snapshot: ... else if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmin(tuple= ))) return false; else if (TransactionIdDidCommit(HeapTupleHeaderGetRawXmin(tuple))) ... When decoding (and replaying) data changes, you deal with the database sta= te as it was (far) in the past. However TransactionIdIsInProgress() is not suitable for this purpose. And since CommitTransaction() updates the commit log before removing the transaction from ProcArray, I can even imagine race conditions: if a transaction is committed and decoded fast enough, TransactionIdIsInProgres= s() might still return true. In such a case, HeapTupleSatisfiesSelf() returns false instead of calling TransactionIdDidCommit(). > Another option is just invent a new > snapshot type - SnapshotBelieveEverythingCommitted - for that > particular case it should work - because all xmin/xmax written into > the new table are committed by design. I'd prefer optimization of the logical decoding for REPACK CONCURRENTLY, a= nd using the MVCC snapshots. -- = Antonin Houska Web: https://www.cybertec-postgresql.com