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 1upPMH-004a2k-Qn for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Aug 2025 10:50:59 +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 1upPMG-004znT-1L for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Aug 2025 10:50:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1upPMF-004znL-In for pgsql-hackers@lists.postgresql.org; Fri, 22 Aug 2025 10:50:56 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1upPMD-001B1Y-1c for pgsql-hackers@postgresql.org; Fri, 22 Aug 2025 10:50:55 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-333f8dd3620so14003191fa.0 for ; Fri, 22 Aug 2025 03:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755859852; x=1756464652; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=x92FwF1uJUdI9BYJma9DtMg15XAKQu16EpN0h1rMnt8=; b=MNpnKoNW01/vt8g9hB6kgmYJGCM4FWnra7/P2oX5k5B7ALyMOcRncB81dNiewispiU iCJ6PGO9OHTKwR29WeTGvqA613QAGbEz4Zldwu+sz7qXwIA8jZSZnZ4ZZeGIKNAwXWZr xBRz3dv+3qzGozTv0zmScJTozFMQ9dpsSZ3CKKPOEt8TCDwa22N2rO4tL3zJ5wPjWGYp ICukCxl7tHc0fVPESXTDfC45+6F750aWEbJnh/ItgASG2OeZoil1jnX/rSc8/xL6unAr 6tg5Ivum3k08GNZPF4wTV75KooEWBvGh03F5KfA6Ynxg4r9b8PPuwyHqap80OalPK5YG hScg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755859852; x=1756464652; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x92FwF1uJUdI9BYJma9DtMg15XAKQu16EpN0h1rMnt8=; b=jUKnCEYSY3aHQOWYUThDsjKckzKorXJ9wV5+CvygSg84scfPWaxkrP5MqKS9L3XIZF V+hzvTvA6CIf1op+ckRtdqE8mAwdtw+iq2JAyySha7+22D6znP9KMU61saMlAwbHg0lX DWgWdDUJZiA4gYEBhaspkf+z9UjLQ1aNkI9rpT8VjrHKFDenG7GR8wHh6UnlDZHnZGb/ +WEILBWV7S3FAOgU+ZtgK3kfBOHniIop7lesXrL/Th9HDr2FRloF0zbSUdNOB4lraw5X 7oKF+2H9hANLOhbCcvPD7J1gmE4IxB5PcAX+b7pS00mmUNGniCIXn6iqVBeT6TbRBDLH h6fw== X-Forwarded-Encrypted: i=1; AJvYcCUVbehyG+yM2kygtSbQdACpUdxp6Ck0O8H4RDPv0px4jek9TaEqwC9R9fK+yfhLUxz826VEJmBoJ4jj9UgK@postgresql.org X-Gm-Message-State: AOJu0Yxdn1U7imTdnLOxPnTaUGI4tk+/kPjBRhpmdCi44oSO117wBeaD HcI0xC63VDN2dNdM3df+bXireIGg9OSQTVyI8nvDMOlzzgRnvPQejTtkW/HOz/hZIfKsNKXR2Ld hjqOGcnGwHIlstdgIszSmxhNCApxR7Cs= X-Gm-Gg: ASbGncsW9w/s/Te2MwhfJWGZxZWl8HFa7YFn/Rc5E7ohix2gxuG/oztXI1Z2KHi0CSM niobXELPmAWI+tw5wJXS0R61SzyCIgcXq2FUxFbHwgS6sVK5bglUEBRpEcHDFQRPqnt8m4TVT+M ZtmUhTXAPwd4PQ5w2VVE62PQymkLNf0xJzjs2hVssQ9/2AFKLiWrNTwr7m17TbTjyhHbCuH+Ziw zkggnCeqw== X-Google-Smtp-Source: AGHT+IGYrwS4FlYb7AcIdCZVyLpXUXjMCDwLWFRcf4L69IFIEkInVr548W3rPTzLYDPF1YtWZvwxka+EpVb50dGKtaY= X-Received: by 2002:a05:651c:1994:b0:331:edf7:f4cc with SMTP id 38308e7fff4ca-33650e98eaemr7649441fa.13.1755859852315; Fri, 22 Aug 2025 03:50:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Fri, 22 Aug 2025 16:20:41 +0530 X-Gm-Features: Ac12FXxNkI9RWDW4OBQFsyqyH-l5qM-YILSFVO5_rYW5qJ4FFQ02Cy1uPZy3fN8 Message-ID: Subject: Re: [BUG?] check_exclusion_or_unique_constraint false negative To: Mihail Nikalayeu Cc: "Zhijie Hou (Fujitsu)" , Peter Geoghegan , "Hayato Kuroda (Fujitsu)" , PostgreSQL Hackers , Andres Freund Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Mar 12, 2025 at 6:36=E2=80=AFAM Mihail Nikalayeu wrote: > > Hello, everyone and Peter! > > Peter, I have added you because you may be interested in (or already know= about) this btree-related issue. > > Short description of the problem: > > I noticed a concurrency issue in btree index scans that affects SnapshotD= irty and SnapshotSelf scan types. > When using these non-MVCC snapshot types, a scan could miss tuples if con= current transactions delete existing tuples and insert new one with differe= nt TIDs on the same page. > > The problem occurs because: > 1. The scan reads a page and caches its tuples in backend-local storage > 2. A concurrent transaction deletes a tuple and inserts a new one with = a different TID > 3. The scan misses the new tuple because it was already deleted by a co= mmitted transaction and does not pass visibility check > 4. But new version on the page is missed, because not in cached tuples > IIUC, the problem you are worried about can happen with DELETE+INSERT in the same transaction on the subscriber, right? If so, this should happen with DELETE and INSERT in a separate transaction as well. If that happens then we anyway may not be able to detect such an INSERT if it happens on a page earlier than the current page. BTW, as the update (or DELETE+INSERT) happens at a later time than the publisher's update/delete, so once we have the last_write_win resolution strategy implemented, it is the subscriber operation that will win. So, the current behavior shouldn't cause any problem. --=20 With Regards, Amit Kapila.