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 1ntqyO-0005Sy-Ek for pgsql-general@arkaria.postgresql.org; Wed, 25 May 2022 13:22:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ntqyM-0004it-Cd for pgsql-general@arkaria.postgresql.org; Wed, 25 May 2022 13:22:46 +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 1ntqyL-0004fw-U7 for pgsql-general@lists.postgresql.org; Wed, 25 May 2022 13:22:46 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ntqyJ-00041e-4A for pgsql-general@lists.postgresql.org; Wed, 25 May 2022 13:22:45 +0000 Received: by mail-wr1-x42b.google.com with SMTP id t6so30130653wra.4 for ; Wed, 25 May 2022 06:22:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=Nmm6E0ICJd4wXXP1caOYscFy2itnY94vzxOQ5dx+lqw=; b=xAqeWQS4iy8gEeZ1XUgvjxUAbQLrajQdt5mSIHUE/Z0/jvDV/NtZQG74cr+/pGMEcI XRwgsrEXh5nm98O2EsdYatr5qHzSb/Eb4KWMAsNfbnIqQ8U3KNBhDzy9xDOxLARB3Y45 h+207ZymXRyia5MmOQTn7GK2EyGCK4mfG1am8338DunFrjnqaJGsR2zqtxTS9q4qLllg nkHZiBNRoFGtaoRN/3xIFhk6LE5w/vf0JZGegfSGem4SnP0bT2iekpArQ8B6aehhYdNQ Lc8RCoR0d/1f9vbEOsn1Rinh+6T6XDbYIktRTysmoTfjnc8w4pTz9DzxYTc7sa2kjFeb Jn+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=Nmm6E0ICJd4wXXP1caOYscFy2itnY94vzxOQ5dx+lqw=; b=NW4FooXiWLQSoPyO+N1CdMw4OUCcWBzMUq3Kl7e3XTu+tktCucyn9xKNvDyRdnNUXo hvfNnPClPXEYEJv45tK6AUDUPRb960jSycWLjMOUopiDW95nrhJuC/U+B/oDLGR24fGS E3z+cXULcGkLmsjcgWWzmIbxh7QuaTW6I+4oE6zLi3+vj8Rx8YsnyR3kDFFsBsHnWEcF 7MR+lfj16TA9Jlh5jm5w/bt033zHki0A9aklDFz97VcsEWhhM3yFEdEB3NGWTy/2G8zH U8TbbH16r1dh8oAiGm2m1/lP05Xwo/ttPzD9glHs8P0R2NJlSjnG0fBLomHVr4exyTQ9 UpDg== X-Gm-Message-State: AOAM530toYiH3ZQz1L1hokUBpVoEAGYioHg3BuGc/6YQIZ9i/J7xhzvs JkPju/OBbBhmVM/MYt85/++F1g== X-Google-Smtp-Source: ABdhPJy9NkH+cWilrCPTWAAs0bZIIiK3h0QjJH3K/efo/WkcWiIVNaRSZymAGPrdJBCMm/s3K1+AAQ== X-Received: by 2002:a5d:56ce:0:b0:20d:b64:8f62 with SMTP id m14-20020a5d56ce000000b0020d0b648f62mr26552677wrw.703.1653484961682; Wed, 25 May 2022 06:22:41 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:1e9:68e4:2e29:6ced:f071]) by smtp.gmail.com with ESMTPSA id 206-20020a1c02d7000000b0039771fbffcasm1115761wmc.21.2022.05.25.06.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 May 2022 06:22:41 -0700 (PDT) Message-ID: Subject: Re: existing row not found by SELECT ... WHERE CTID = ? From: Laurenz Albe To: Christoph Moench-Tegeder , Matthias Apitz Cc: Tom Lane , pgsql-general@lists.postgresql.org Date: Wed, 25 May 2022 15:22:39 +0200 In-Reply-To: References: <1652228.1653408709@sss.pgh.pa.us> <20220525120112.GA17@sh4-5.1blu.de> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2022-05-25 at 14:27 +0200, Christoph Moench-Tegeder wrote: > ## Matthias Apitz (guru@unixarea.de): > > > We will solve the problem now with setting the session after connect to > > > >    SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ; > > > > (with an appropriate ESQL/C call). Any comments? > > Maybe the real question is whether it is wise to use an implementation > artifact (ctid) to identify rows? > The textbook approach could be row locks (SELECT ... FOR SHARE/UPDATE and > variants) to prevent concurrent changes or optimistic locking  (and a > primary key in any case) - but maybe you already investigated those options? Right. REPEATABLE READ won't help you there. True, you will see a stable snapshot of the database inside a single transaction, but if a concurrent session has modified the row, you will get a serialization error. So that is not a solution. Yours, Laurenz Albe