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 1nvvV7-0003al-KC for pgsql-general@arkaria.postgresql.org; Tue, 31 May 2022 06:37:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nvvV6-0004tX-5b for pgsql-general@arkaria.postgresql.org; Tue, 31 May 2022 06:37:08 +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 1nvvV5-0004tO-RA for pgsql-general@lists.postgresql.org; Tue, 31 May 2022 06:37:07 +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 1nvvV1-000487-2h for pgsql-general@lists.postgresql.org; Tue, 31 May 2022 06:37:06 +0000 Received: from [188.174.62.38] (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 1nvvUv-00063w-LP; Tue, 31 May 2022 08:36:57 +0200 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.unixarea.de (8.16.1/8.14.9) with ESMTPS id 24V6auoN001438 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 31 May 2022 08:36:56 +0200 (CEST) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.16.1/8.14.9/Submit) id 24V6atV7001437; Tue, 31 May 2022 08:36:55 +0200 (CEST) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Tue, 31 May 2022 08:36:55 +0200 From: Matthias Apitz To: Tom Lane Cc: Ravi Krishna , Laurenz Albe , pgsql-general@lists.postgresql.org Subject: Re: existing row not found by SELECT ... WHERE CTID = ? Message-ID: Reply-To: Matthias Apitz References: <1652228.1653408709@sss.pgh.pa.us> <1924203.1653489504@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1924203.1653489504@sss.pgh.pa.us> 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.62.38 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk El día miércoles, mayo 25, 2022 a las 10:38:24a. m. -0400, Tom Lane escribió: > Ravi Krishna writes: > >> No. PostgreSQL may remove a dead row, but a dead row is by definition > >> no longer visible, so it wouldn't be found by a query. > > > I am wondering whether it is a good practice to use CTID in a where > > clause. > > It's fine if part of your business logic is that you don't want to allow > concurrent updates. In this case, the OP seems to want to prevent rather > than tolerate the concurrent update, so I don't think he needs to revisit > the app's use of CTID. > > If you do need to support concurrent updates, then yeah relying on CTID > is likely to be problematic. Tom, we detected another issue of missing a row by its CTID in another table where fees are stored which one(!) process cumulates in the night. The time window between creating the CURSOR and missing the CTID is only 42 seconds and I can not imagine that any other concurrent process is updating such fee rows at midnight. Could exist any other reason why a row changes its CTID? Full VACUUM is not used either. Thanks matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub