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 1v6uH7-00BgXU-9L for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Oct 2025 17:17:57 +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 1v6uH5-007Yvw-1t for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Oct 2025 17:17:55 +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 1v6uH4-007Yvm-Pl for pgsql-bugs@lists.postgresql.org; Thu, 09 Oct 2025 17:17:55 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v6uH3-001H1V-1a for pgsql-bugs@lists.postgresql.org; Thu, 09 Oct 2025 17:17:55 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 599HHqTD3080221; Thu, 9 Oct 2025 13:17:52 -0400 From: Tom Lane To: cuiziyu20@otcaix.iscas.ac.cn cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19081: Inconsistent target rows seen by the UPDATE and INSERT statements within the same transaction In-reply-to: <19081-3745d3e571c420de@postgresql.org> References: <19081-3745d3e571c420de@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 09 Oct 2025 15:44:15 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3080219.1760030272.1@sss.pgh.pa.us> Date: Thu, 09 Oct 2025 13:17:52 -0400 Message-ID: <3080220.1760030272@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > After transaction 1 was committed, the second INSERT in transaction 2 > successfully inserted the value (0, 12) because transaction 1 had updated > the row (0, 0). However, the UPDATE in transaction 2 did not update the row > (5, 5) that were updated in transaction 1. > The final database result seems to indicate that the second INSERT in > transaction 2 can see the update made by transaction 1, but the UPDATE in > transaction 2 cannot see the update made by transaction 1. Why do these two > statements show different effects when exposed to the influence of > transaction 1? I don't see any particular contradiction here. At the time of T2's second INSERT, the removal of the original (0, 0) row has already committed, so there is no reason to disallow that INSERT. REPEATABLE READ does not intend to promise no serialization anomalies. SERIALIZABLE mode is a better approximation to that if you need it, though it has its own downsides. regards, tom lane