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 1xH3LD-00000002nbB-2ckA for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Oct 2026 18:04:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xH3LC-00000004juU-2u2m for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Oct 2026 18:04:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xH3LB-00000004juM-28mb for pgsql-hackers@lists.postgresql.org; Wed, 14 Oct 2026 18:04:38 +0000 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xH3L9-000000021CQ-1iAG for pgsql-hackers@lists.postgresql.org; Wed, 14 Oct 2026 18:04:36 +0000 Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfhigh.phl.internal (Postfix) with ESMTP id 55A0414000B8 for ; Wed, 14 Oct 2026 14:04:34 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Wed, 14 Oct 2026 14:04:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm3; t=1792001074; x= 1792087474; bh=WfZhmI9IdmjLCp8A837QLhfftiTZxc3hVqAhD3trTnA=; b=D O4eBzdsgLpLsKd8qiYzjEnwtMGLsefCsG6tzNCtzw6Q1j2uPAKF3kwYwX02iHB3z A4wHzIi7XI7MhresU9c7UFGLB/lNWklC7gSsOQiN87oA8c7lilr1+tkdDDZbnuNv ucwyue5Djd6ZykUWnPpm8pj2tyDFU38qiSBqwae6oTjT1b+3G0KDgEwx+efhoUqB +ZnZfGdsOtouTb3KfSOZrhgqQ7OwblhKYJdCdifrygnvpsiNhfCfViiydjsOoQAG js+aL027n9jUioRoobXSOGvq7XoRn+xwwJckKIsF1cLizWzKrox6zReuIN+zja0A TmfbpDA6Hrdg7SHKeVLZQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1792001074; x=1792087474; bh=W fZhmI9IdmjLCp8A837QLhfftiTZxc3hVqAhD3trTnA=; b=xgwQMHFpfOUpMkWh4 bbknmelq/4e3fqnKy+pmYOy5sU2Tr72paDuYb4oTtlyYs7WoqDqnCFFDmtY+duNT pmPqS5fokasKyAhJ9Q+tW3sE2KDGMNy+8rQ2nHoVmgCMPf5hWp1BJ2NcFtYeY6dn miDbQZjMEzU3aetMM4JeLXdPg20aFLuPTJGPG5cNvnLEhSr4TG07auZrVrEBIBy9 4w03s11Gni5rv9QTu7/W4Ecewx9DRJz6hriE1VKq+7q96mf4u0XV98Y3xukdnZ4W ccieKQwNLeqkUFoTV+MfybyX0dFreoRdvNv0JbuKLoG1YpCl/HoOCBWpqZWOByrC cRJRg== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-06; repo=github.com/dkim2wg/interop; date=2026-10-04; sw=lmtpprox; action=sign d=kurilemu.de a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1792001074; d=kurilemu.de; mf=PGFsdmhlcnJlQGt1cmlsZW11LmRlPg==; rt=PHBnc3FsLWhhY2tlcnNAbGlzdHMucG9zdGdyZXNxbC5vcmc+; s=fm3:rsa-sha256:xgDTX/tgnuMlgfaLA5uPXgaXAmdYBeBi+xSA5BIWZyV7Gi3 Yl8sV3FpVTR+KAvIGOrQabyGHLqMVCHosRuBcJ8eWkuQ99KrIlzwkaFWbEHXRCxm zGWatq0IzRwz5CcQLzhnFAuRqYyX6FVT3ltCr/wVin8qDMd06q3ZAzzYvrHG5sQN x+/IauG+aTunlDqeSLDb/+Qud4rJJ3vNNnVJiA5XpbSy6uYWxD/47ek9JP61wVix ghU4gtupT258Mtwmgy9pT8gNtfh6Y1qJn9pf51xiA5oNO9I+6KuZRmFrF/4+R9Dh LMjt/pGIGknlOTidty3uH8TuoY0qE/bfX+aEAEw==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-06; repo=github.com/dkim2wg/interop; date=2026-10-04; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-transfer-encoding, content-type,date,feedback-id,from,in-reply-to,message-id, mime-version,subject,to; Message-Instance: m=1; h=sha256:ymnDBZz003sYStsTrkSdrKV3v4YYNjlfnRoC52IAXcI=:dZL1ll3mHAq+59suYQRK7VomYhqxcNOiWtkoZX08Auc=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFeGtjMsLG805ToGZR03W/Ohc2pomHD2l9rB0/NJa8908Dblh5H0G4FXT4MbxFCkl WGmH5PUo6dsttl4soz5rECziuwUydYiaqL3RlrNo7Vp/8uY7z2KJXUr9a9SjdPhPV0S9sj L9jmiwSw2zSBiZZfh1OXwnAc5krw3HrwY1p/pIme1rEnGznKLO76KSjqXLmGMGbU/MIwEX v+SUx4xKnkhHt7NlQZuYkV8vsVoB22gZL6/frR4++3YQ2hKhRrNbpNa2zQjBhKWSNkCohO 3bYRPnYC93K8Yv1KJxC/qnXWHiDJVErm8Z0nDynrHuCn7Ot6QjuYBypMGWvy7dqtZiqbsw aHxFCRkVo3B0S609j1VIIkT5VdFZOqnYlcU3T2AKu82D8cehASbheb2Yig5QVRlW1gPJ4o gOx/4cL1UdcFksAN3E/hw+Vebclsaj6u+5Chx5Q5hb5166AWOpNRGOBLTPMN2fDOMYlw2P nBj1peQvPv04vfeiT9uMnZws3AHsqyGoXha1k/3+Il8ZlpkIXwoTq8BKR8PGDV2fifhH9Z zDvj9EfMpJ+O5jta17mlIDohPZKR5DRVup8MK1CqEKbcw8RkxYMSIXQsgZ5bBeXJh0jF/Q 3oEgStSzrY4ptZUmGyFq23e5aPuN4L5CJ9B6fFc6o7m2LbnlbubZB8tuNdxg X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 14 Oct 2026 14:04:32 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1792001067; bh=dZL1ll3mHAq+59suYQRK7VomYhqxcNOiWtkoZX08Auc=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=FBe0HtQdhEC/svEm1cjJyBp6Exp4vKgMefN7mg/Jp/PBqgDSWVL0l5NGx+AJFpSVf 2yZO3byr6+XhYSmFBBr+y+EkQ6S40qi4xrkZAKbsGg38cFJ+/MxDIHhaZvlnjFGkV0 3x13jTzDoHTZqa2f0t4qtO8f7D9doaFdkYMpD17JGXyBMTrbgM8KKl3xP00H2V/2Fv RLucH8xJGTn9upzeb5TJdxdvcr6vmxsggqs4AtVVxLWbrneSxi/Ehpq+l7gu/HUnLM QgVplsL0jntoJ/mqWQyyno1NaOCgCRWgHVaVJ2pAvYx52gs6vRsZgMPMO+y1XHdaoe ciavP0XFrC9nA== Received: by ida.kurilemu.internal (Postfix, from userid 1000) id 20703B00192; Wed, 14 Oct 2026 20:04:27 +0200 (CEST) Date: Wed, 14 Oct 2026 20:04:27 +0200 From: "alvherre@kurilemu.de" To: Bingshuai Li Cc: Zhijie Hou , "Hayato Kuroda (Fujitsu)" , Michael Paquier , Tom Lane , Alexander Lakhin , "pgsql-hackers@lists.postgresql.org" , "mark.dilger@enterprisedb.com" , Amit Kapila , Masahiko Sawada , Andrey Rachitskiy , "a.kozhemyakin@postgrespro.ru" Subject: Re: Bug in logical decoding with DDL and subtransactions Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, Many thanks for the reviews. I have pushed this to all branches. On 2026-Oct-14, Bingshuai Li wrote: > Agreed on the guard (+1); for the record, I reproduced the cfbot > failure locally on master 36a56229765c plus v8 with the same sanitizer > flags -- the stream test loses its backend and the one-line return > makes the test_decoding and isolation cases pass. Right. > One correction on the comment, though, in the "not known to be a > subxact" paragraph: I don't think "there cannot possibly be TUPLECIDs > to clean up" holds. The NEW_CID gate is on the snapshot state, but > the association needed by this abort cleanup is established when the > subxact's first WAL record carrying its toplevel XID is replayed > (LogicalDecodingProcessRecord -> ReorderBufferAssignChild). After a > restart, a saved CONSISTENT snapshot can be restored at a checkpoint > past that record; later NEW_CID records still pass the FULL_SNAPSHOT > gate. The subxact then gets an entry via ReorderBufferProcessXid with > no association, while its TUPLECIDs are queued on the toplevel. That > is the state I reported upthread (entry present, not a known subxact, > tuplecids on the toplevel; the toplevel commit skipped). > > For this unassociated-subxact case, the early return need not mean an > empty list. If the toplevel commits, that commit was already consumed > before start_decoding_at; SnapBuildXactNeedsSkip() skips it and > ReorderBufferForget() frees the list, never reaching the tuplecid hash > -- as Zhijie's v7 comment had it. If the toplevel aborts, > ReorderBufferAbort() frees the list. > The existing parenthetical already covers the top-level abort case. > Minimal suggestion for that paragraph: > > * We return without cleanup if the aborting subxact is not known to > * this reorderbuffer. It may still have TUPLECIDs queued on the > * toplevel if this snapbuild missed its first WAL record carrying > * the toplevel XID. A commit that could use them was already > * consumed: SnapBuildXactNeedsSkip() skips it and ReorderBufferForget() > * frees the list. A toplevel abort frees it via ReorderBufferAbort(). Okay, I adopted this, but made still more changes to it, mostly because I don't think we care very much about the memory freeing; we're mostly concerned with whether the catalog tuple processing is correct. But I also changed how we talk about the subxact being "unknown" -- I mean, it's not that it's really unknown; as I understand it, the problem is that we don't know that the parent is the parent. I also think that talking about SnapBuildXactNeedsSkip() is a bit indirect, so I mentioned DecodeCommit instead. There's quite a bit of abstraction leakage in this whole thing, which is probably unavoidable. I mean the relationship between reorderbuffer.c and decode.c and snapbuild.c. It's probably not surprising that this patch had to touch all three. So I don't feel bad that the comment in reorderbuffer.c needs to mention the function in decode.c. BTW you mention Zhijie's v7, but I think that comment mostly comes from your version just prior to that ... > Also, in the inner comment, the clause "or that we entered FULL_SNAPSHOT > after the subxid was assigned as a child" doesn't work as an > explanation for finding no entry at all: ReorderBufferProcessXid creates > the entry before the snapshot-state gate, and a later transition to > FULL_SNAPSHOT does not itself remove it. Dropping that clause (as in > v8's wording) reads correct to me. Okay, done that way. > And thanks for the terminology fixes; "decoding pass" was indeed not > the codebase's language. Many thanks for double-checking. Feel free to propose more wording changes to these comments if something is still wrong. At least I think we're better than when we started ... -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ Officer Krupke, what are we to do? Gee, officer Krupke, Krup you! (West Side Story, "Gee, Officer Krupke")