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 1uqrXU-00EFsq-MO for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Aug 2025 11:08:34 +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 1uqrXU-004zxt-2V for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Aug 2025 11:08:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uqrXT-004zxl-PY for pgsql-hackers@lists.postgresql.org; Tue, 26 Aug 2025 11:08:32 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uqrXS-001wNb-1O for pgsql-hackers@postgresql.org; Tue, 26 Aug 2025 11:08:32 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-55ce5243f6dso5851937e87.2 for ; Tue, 26 Aug 2025 04:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756206509; x=1756811309; 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=QB7InV4VkEyQIOA608jaoIWEBJiE9BLlWNQhd/MHT+A=; b=CRr/2xfZA3assBK2Rl8WgtHasavGv4/CFgwIXI9dS1bvhK8pkhH/TKvLj3wt1KsnD1 Gfavq+pKExUCPsKg/BtsANkQAoFOuAFNtIGVYCDybvqvsApbzle/lMaPa/zE1T5iU5vY BOWrUkEznhQtcyygLXp0ZjNekc/ygUe7rdyQWdnHgPsjtroVn2CNRXAcPqZjhOLlLdF2 TNSKnwkli5WCg7tqNjQsNrfZNxLg0ChGCmV+ogEGcaASyDMufcX/NdjioHdMkTzKlo89 XLU8l8ehtzrwzNyjyaI20SNh+73nsQFI753BL6woXjUnLcIM/BzJ9SMaUlltzUqRut+a VMKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756206509; x=1756811309; 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=QB7InV4VkEyQIOA608jaoIWEBJiE9BLlWNQhd/MHT+A=; b=r2mcZhqsUGch2dWUHK5nDawaOF/NrEZcZxBkFSWdEm5jH5xL4Y+d/gyf84m0Ev/F9R ZVXhxGsXbOeihJWWaH3awabSs+zNK4cH3DuHFsXAc2g7ZlgxX1Ea3Xs+eXcEnazJbuQE vPaRU5tKRM7q9lS+x2AzcAVa5PaKZUrTBkotIGq6YOe85SoyuwgjvomtxwTZV/Zn3O00 JmSwtiyv1sE1qCpyAZYs8BNGnww7goO/1v57aTRsA8fOVjA38lwbFhzSUvXkByUTYy3V WI8asUzyFBZvG2wJZnwAaFsGeYKkRcsqZa1andhQryv6Ns/vy0z8Tl7cc5t5pfbtuXFV WOSA== X-Forwarded-Encrypted: i=1; AJvYcCWgCF07DB3YfvBhFkDImsGxk1Nbh3VtCf7dBYzY/Of6SZV7QA1d1FGBDqnC8VdS5c0qC2FivSrqWcjOG234@postgresql.org X-Gm-Message-State: AOJu0Yx1EBCrR6gDUwwjNtO1amG1ezvQtp7MELA84I/nQeUh52mbF5nS 6uAV7dBkEZIOXz4gpK30dXZmsCpyHz1jLXb3IktK24fTjMOaeC3VEXBTl8PPiayul7i2qN9slvl W0sVPYdWXR1aoW4FOaxKkMLWRiGG/yvo= X-Gm-Gg: ASbGncuEMomqPJ4lE42GgwoXpP2u3+73IztiuRFGHFEwZFj+mnatIREFjmHhFPNr45R adoZ0nZkSzNBJQyvTPcCFUHhQorppA0X0kxwhSAc/D8wdh+dIoCiOij41Doo72XUoLzPg6foc1G 2wq49puZCCtkfYU+9sfgJTwgVI6ix8z+tdfyy+hisWXl3i90v1f1WGN1gPMVDGAZfl67GKJlLd/ gn5o+yUz8KQ5sKEUQBL X-Google-Smtp-Source: AGHT+IGadtG5NFVBB9ryVl4gsqtylOtBpyqpsAohO/tqPZJ9xul6RND2GCKBDPNMKcf8BGJNv0wgDfxbzRywSXoU4Cs= X-Received: by 2002:ac2:51d2:0:b0:55f:4321:4ad6 with SMTP id 2adb3069b0e04-55f43214c9amr2408925e87.44.1756206509135; Tue, 26 Aug 2025 04:08:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Tue, 26 Aug 2025 16:38:17 +0530 X-Gm-Features: Ac12FXwIqY-q4y0ohK0pYr72DphTPMcZdhFaSEpb0reTekmCQiJ70XjpWkyKBPk 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 Mon, Aug 25, 2025 at 7:02=E2=80=AFPM Mihail Nikalayeu wrote: > > Amit Kapila : > > > > What if the new insert happens in a page prior to the current page? I > > mean that the scan won't encounter the page where Insert happens. > > Hmm.... Yes - if the TID lands to the page left of the current > position, we=E2=80=99ll miss it as well. > A lock=E2=80=91based solution (version in the v10) would require keeping = all > pages with the same key under a read lock, which feels too expensive. > Right. > > BTW, do we know the reason behind using SnapshotDirty in the first > > place? I don't see any comments in the nearby code unless I am missing > > something. > > I think this is simply an attempt to lock the newest version of the > logical tuple, including INSERT cases. > For an existing tuple, the same can be achieved using MVCC snapshot + ret= ry. > However, in the case of a not-yet-committed INSERT, a different type > of snapshot is required. > > But I'm not sure if it provides any advantages. > I think it is better to document this race somewhere in a logical replication document for now unless we have a consensus on a way to move forward. --=20 With Regards, Amit Kapila.