Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o94DE-0006vv-UR for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 12:33:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o94DD-000204-9x for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 12:32:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o94DD-0001zv-00 for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 12:32:59 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o94D9-0006r0-02 for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 12:32:58 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 16F945C01AE; Wed, 6 Jul 2022 08:32:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 06 Jul 2022 08:32:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1657110772; x=1657197172; bh=Y FqaBTD1CLVx8LfR+DRLjy8uwZgw8X12PBT/NFax9Ic=; b=cfplkeAZiE9e3KHi3 oy63p5WeEgctdFi2ilYJRzZBVzgenV9gcEhJPmNke0MCSUmcdTaYKQpFe+Svbnpb UyblyGjGNZKCZEwrr3VfV3oERJzImUCWptlLzoAisfiXnsWxnk0jz4czS3LNB+oh AOzep7xWZrGXv2OvtswRQPEitbw7nYtffOVWHNpyW7Q36kF6ys3Qn5uI5nFHcEVS pUwERsMyp4Hk0h2s7WP8ijZTjAOL8cst2UtgSdZwAsnEsrz2+xOhRdDA2lyn23UP MGlLIwlECob9/i6SDPJmXiIUzq97b0h9RHQC9NdzRwTR/9/cG7RgemM/slAi0J0E SJ/DQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudeifedghedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepvdektdffudfftdffffehfffhjeejhffgieeuueekjeek fffgudffhfduffffueevnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Jul 2022 08:32:51 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id E988035D; Wed, 6 Jul 2022 14:32:48 +0200 (CEST) Date: Wed, 6 Jul 2022 14:32:48 +0200 From: Alvaro Herrera To: Matthias Apitz Cc: Karsten Hilbert , pgsql-general@lists.postgresql.org Subject: Re: lifetime of the old CTID Message-ID: <20220706123248.6uy4sgf3owl64kbr@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220706122600.GA24@sh4-5.1blu.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Jul-06, Matthias Apitz wrote: > This gives in the DB layer a CURSOR of say 100.000 rows of the > 3.000.000 in the table. Now the application fetches row by row and see > if something should be done with the row. If so, the DB layer must > LOCK the row for update. It does so using the CTID. This is a bad idea, for reasons already explained. The CTID is not for user consumption. If it breaks, as it does for you here, it's your fault for using it. Your rows need to have a key that you can use. The CTID is not it. > Of course there is a key in the row (d01gsi, the signature of the > book), but this is not uniqu and can't be used to lock exactly this > row for update. Well, you need something. It is beginning to sound like your database model is wrong, because it lacks sufficient keys. > Interestingly, I tested today morning how long the new CTID can be > seen with currtid2(). I did 10 or more updates of a row and the then > new CTID could always be seen with the old CTID from the moment before > the 10 updates. I even found no way to get this tuple broken. Only > deletion of the row helped to make currtid2() loosing the relation. > This is with a 14.1 server. Why the 13.1 behaves different? There are implementation details that you shouldn't concern yourself with. Quite likely, the reason it stayed unchanged has nothing to do with the server version, and is instead related to other things happening in the server at the same time. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "I suspect most samba developers are already technically insane... Of course, since many of them are Australians, you can't tell." (L. Torvalds)