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 1o968N-0003fK-HP for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 14:36:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o968M-0006Bk-ER for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 14:36:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o965C-0003eJ-9Q for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 14:32:50 +0000 Received: from ms-10.1blu.de ([178.254.4.101]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9659-0002FH-9t for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 14:32:48 +0000 Received: from [188.174.58.154] (helo=localhost.unixarea.de) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9650-0006D3-H1; Wed, 06 Jul 2022 16:32:38 +0200 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.unixarea.de (8.16.1/8.14.9) with ESMTPS id 266EWbg5005337 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 6 Jul 2022 16:32:37 +0200 (CEST) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.16.1/8.14.9/Submit) id 266EWZfx005336; Wed, 6 Jul 2022 16:32:35 +0200 (CEST) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Wed, 6 Jul 2022 16:32:35 +0200 From: Matthias Apitz To: pgsql-general@lists.postgresql.org Cc: "Peter J. Holzer" Subject: Re: lifetime of the old CTID Message-ID: Reply-To: Matthias Apitz References: <20220705102201.GA9@sh4-5.1blu.de> <1c03b94b606f493bc6448b8559c4cccf806d3607.camel@cybertec.at> <9B418AE6-EA48-4493-B1D1-566708ADC9AC@thebuild.com> <20220706122600.GA24@sh4-5.1blu.de> <20220706135354.e7nxo2vyrxwqlkce@hjp.at> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220706135354.e7nxo2vyrxwqlkce@hjp.at> X-Operating-System: FreeBSD 13.0-CURRENT r368166 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 188.174.58.154 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk El día miércoles, julio 06, 2022 a las 03:53:54p. m. +0200, Peter J. Holzer escribió: > On 2022-07-06 14:26:00 +0200, Matthias Apitz wrote: > > DB layer must LOCK the row for update. It does so using the CTID. 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. > > If it isn't unique it is *not* a key. If your tables don't have a > primary key you should seriously rethink the data model. This Library Management System runs already for 25++ years with nearly the same data model. We came from INFORMIX, then Oracle, then Sybase and since 2 years are now on PostgreSQL. There was always some serial key for the rows (I don't remember INFORMIX, but 'rowid' on Oracle, SYB_IDENTITY_COL on Sybase and now CTID on PostgreSQL. The error we made two years ago was not investigating carefully enough that the CTID is pruned even before the changed row is deleted by AUTOVACUUM. Now we know this and will deal with the problem above the DB layer which returns now a fixed return code when the row can not be found with its old CTID or a new CTID can not be calculated. Said this, we can end this thread. Re-think the data model is not an option. matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub