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 1xHY6Z-0000000366P-3AM7 for pgsql-bugs@arkaria.postgresql.org; Fri, 16 Oct 2026 02:55:35 +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 1xHY6Y-0000000C7Vn-1v8j for pgsql-bugs@arkaria.postgresql.org; Fri, 16 Oct 2026 02:55:34 +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.98.2) (envelope-from ) id 1xHY6Y-0000000C7Vf-0qNW for pgsql-bugs@lists.postgresql.org; Fri, 16 Oct 2026 02:55:34 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xHY6W-00000002O0r-09Hj for pgsql-bugs@lists.postgresql.org; Fri, 16 Oct 2026 02:55:33 +0000 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-3ab4178ee33so3511297a91.3 for ; Thu, 15 Oct 2026 19:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792119330; x=1792724130; darn=lists.postgresql.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=0cqdFGVSAELm/MBBfWMF1mPHIBzJ5t1+KF6LOS1dgrU=; b=l+5WyiB5Vtfw8ncVGjeAI0mrbisU2dhwX8jQBHEaApz4nUTrP7tkFMPQQO4f07qo/2 f71XBrVZS3mPUPWyyHMOO/h4lySBJsNiAXkZlAd/pgxxJibsOrLT+eyP/iekd8AIb3XF DrTJKXYwC5YEzbCtrMH8SoKv/S4rAzEN/SVB8U9OeurujY6oHxmaA1inmrTrryCuuFlR stiPsB+kxZlJVRFuofpvzTQIdJQ5WDWRie8U5bgHRW+l9ch9LakIOSrQp/k9tqkvlzPi nQlIAHps29A8nKgz4c/NbrniEx43JRkRuDSUbc4rVK9GdxStq1LglkuFFdwnsAEuvAUH 7jHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792119330; x=1792724130; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0cqdFGVSAELm/MBBfWMF1mPHIBzJ5t1+KF6LOS1dgrU=; b=M0tUj1/X1eMNGE3e7CWBKHRXO6PxXx0qZfPLkias7B1CUhcHAc75ytYYj/TZRh6r3y vwy0G92ZVXYiZeE3zGhsGqkoyH3gWyXF1aLIHpJEVSxU6rEv+Fo3wwOH86imWa5wRijz /vzLBcSME677o0QrK5RIYtSxxsuCqrtd3VXu5rA4Uo/ZgxjsHD/r+nasCdZFve0uISvf Ez5greTImYqMaKfl4Q+DvvDP8kiDm1QNxV0BH446lafb2tTPoxv9BvsaXl6pB5cmf6ip JnGxnp+XsSPcMUgRd7KW8LIQD8gi887RsPsgcFkiC/HkNELxp9EVNG2rSpzLBl3GTeHm Dy0A== X-Forwarded-Encrypted: i=1; AKwUvBzOEkqGnUbGgqzxuQGGwlMmLUnKae3bby8gY8ReacAdIPrLfEsu2eGBOyVb5ApPVqj7BFnEA2nnA9rC@lists.postgresql.org X-Gm-Message-State: AFq9FYIL9KOsvF40D/9gDPYFf6EwFtJfThy11vfxdFvm4WTksV1sNwKi PdqaryKVMaBE6DgjWmLZPIW1tR0oIJ48iudOYlVBIMmtbfDan8ZnIAXe X-Gm-Gg: AYBFou2/iaOnhhPwiE/spfhgFocUBTwxjck65MNHtlgxa7haXuNlD0HBaGwmismLeFq Lt72Q7MzVE2eRSobk9C5fXUo4vg4OKXfqfpUNyNpt4wh06GktGHExhai9D/UyXsdbyc2qf1Q3+f pspjbv/WyouqBnauIiGi5B2G/i58rNtCurkhjys5kJSQ0FGoNzKhFoyh2x6Qv6XvJWC4+tffCzd Kk05kR0azYsq0RKhbKX4t2gaaN3UFlIfn0LK0BO8DEmHzQ1upgP0rR9ctz3/YpDP/O1QeSC2MWz 2YG/dqCSUx3ZPdb70amF+m5xQeCvdau3KNFh5og0R4oUIQtNMQOUDBeE6WNqpliedb2ss2wVB3O OMECn/u9VnR0Ij+A1t+81075xpPWY6UqMPQaI1LNGOhqbdsyiF1ytbLz8cDOuCv4S8xO86lK/o1 jrY0nDPvXEQwAtrq6TsbQPeI9KQtlJjKTP1QC1AVmrd6+Y1560OeG4JkKGd1K9NucOg1R+seSKv i86/4367tjXW6FdTgJRmScPb5DfWyw21uZ+Syx9LJbDtIqftaS5v4/m X-Received: by 2002:a17:90b:4a08:b0:3ac:4e91:bff7 with SMTP id 98e67ed59e1d1-3ac4e91c1b6mr7322344a91.48.1792119329607; Thu, 15 Oct 2026 19:55:29 -0700 (PDT) Received: from [192.168.1.19] (58-190-153-33f1.hyg1.eonet.ne.jp. [58.190.153.33]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ac945e72c6sm6891033a91.5.2026.10.15.19.55.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Oct 2026 19:55:29 -0700 (PDT) Message-ID: <41175da6-293f-4b8f-ad18-3636f3d8a2f6@gmail.com> Date: Fri, 16 Oct 2026 11:55:27 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #19760: CLUSTER loses a row the transaction inserted and then updated in a rolled-back subtransaction To: alpkeles99@gmail.com, pgsql-bugs@lists.postgresql.org References: <19760-8f9a0eba17bc8c92@postgresql.org> Content-Language: en-US From: Takeshi Ideriha In-Reply-To: <19760-8f9a0eba17bc8c92@postgresql.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Thank you for reporting this. > > CLUSTER (and REPACK on master) silently drops a live row when the same > transaction inserted the row and then updated it inside a subtransaction > that was rolled back. No error is raised; the row is gone after COMMIT. > > CREATE TABLE t1(c0 int, c1 int); > CREATE INDEX t1_i0 ON t1 (c1); > BEGIN; > INSERT INTO t1 VALUES (1, 1); > SAVEPOINT s1; UPDATE t1 SET c0 = 2; ROLLBACK TO s1; > CLUSTER t1 USING t1_i0; > SELECT count(*) FROM t1; -- 0, expected 1 > COMMIT; > SELECT count(*) FROM t1; -- 0, expected 1 > While I was reproducing the bug, I noticed that if we SELECT rows before CLUSTER, the issue won't happen. This suggests that not setting hint bit is very likely to be related to the issue. ---- BEGIN; INSERT INTO t1 VALUES (1, 1); SAVEPOINT s1; UPDATE t1 SET c0 = 2; ROLLBACK TO s1; SELECT count(*) FROM t1; -- SELECT before CLUSTER CLUSTER VERBOSE t1 USING t1_i0; SELECT count(*) FROM t1; --- -- RESULT -- count ------- 1 (1 row) INFO: repacking "public.t1" using index scan on "t1_i0" INFO: "public.t1": found 0 removable, 1 nonremovable row versions in 1 pages DETAIL: 0 dead row versions cannot be removed yet. CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s. CLUSTER count ------- 1 (1 row) COMMIT count ------- 1 (1 row) > REL_18_STABLE 4d62ef92fda. CLUSTER VERBOSE reports a > negative "dead row versions cannot be removed yet" count (-1 here). The value is tups_recently_dead in heapam_relation_copy_for_cluster(). tups_recently_dead decreases only when rewrite_heap_dead_tuple() returnes TRUE in rewriteheap.c. I guess there is something wrong with visibility check invloving hint bits in rewriteheap.c. I'll look into this further. Regards, Takeshi Ideriha