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 1uqXJS-0084it-Qz for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 13:32:44 +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 1uqXJS-009edO-5k for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 13:32:42 +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 1uqXJR-009edE-SH for pgsql-hackers@lists.postgresql.org; Mon, 25 Aug 2025 13:32:42 +0000 Received: from mail-vk1-xa2f.google.com ([2607:f8b0:4864:20::a2f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uqXJQ-001fEN-0Y for pgsql-hackers@postgresql.org; Mon, 25 Aug 2025 13:32:41 +0000 Received: by mail-vk1-xa2f.google.com with SMTP id 71dfb90a1353d-53b09bdcb73so4368853e0c.1 for ; Mon, 25 Aug 2025 06:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756128760; x=1756733560; 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=FLL6u7FHk3qV6pgSSl6t0Do2cmZf0XENoAs2Hw1Parc=; b=BsBxp4XMkamKSbbJa/q3+Qv6NZ/I2S0ax7gzwqo6DbTeZgHV3C9C7s5HTZPgzCJR1d dp6B0r/q8rtWNAhCnrl8nrntYvafPJh6cBl1LoPQGSNT67vBv1vKsFpg5C6V0jkJ7QK6 tXDLSZfMSE9mkEfdffKAj5eXTdHhGERxwqXdgHnsyyvdcoBlswT8dzWzbL8N/cD/7zzM Nkuk4/u+pRqT8fQhWRfaypGQOer8GaspwTyAl5bQja1TOZrEU42CYNtyWsnIQaQ+kZKy rGrBvy69Qjh/SE0sUs7dRRMvpb2pE3nZO3fFMo7bGYiWS4bw/uMOMyEEezd5h64bfGpa cFnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756128760; x=1756733560; 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=FLL6u7FHk3qV6pgSSl6t0Do2cmZf0XENoAs2Hw1Parc=; b=Ythshq4ALX4WDwv3gqMKlj7S3X4HpPgdZ355at0AJdUl2F7Qz/cASOf5ABkW08+FV+ M152Ns+NYAI9sgaPC5L7cA0rRKy/z/zmcyzzlCtqJ0iMe4OdJ7iTGIx8MeX7QU+VB7AE z6B6+W7eMONuAPm1zBawLvko8VpoBz1ei+nsrQRVMLTCXszoUFdH1kCszXY9WiQNaP4z oKhBGzqb0wPBTng2NCoG0gx6sVF1yHm5T2fJiJqtFVUiRkSl2gtzLBbtI7cRYwJMmOoI RcDoMRfEpKWoIQ7zol5KnxLrbIyOhbaCdz9IRtHdsA2cOIzPrmqv4b4GsoAuvbdzeloY L0jw== X-Forwarded-Encrypted: i=1; AJvYcCUFqi29QZhOQEedM9eBUxxVJy68b7ITupMy6p/BAhVoFoQ4mcXuP+CMtPcWY0Q9ZzcoQxpx/xDirD4XmwED@postgresql.org X-Gm-Message-State: AOJu0Yz1oveUPECHDRDaqXjolEHmktEAd/vQ3ngPuRSNevJTtOZsnmZX snRUu9NAd0MldqUgDf84Cj1E4spkfQw27BBHW4MNUMN4Ev20UBPuZwrSAy3f+JjpRo9phaB8FEF nDpPgpFf9vVV29lvFhOCfW0DsY3Ap8QU= X-Gm-Gg: ASbGncseeEvRnLkZt7aNFcWg/t2JtQdlS3uHzHsQkZyaWmsfXc+K+BwSNOg0sUlt+L0 h6tgkv9RsbKzFK03u5AwWYAWqDZ3IC6WXse8t+HtUBBWhcdxGBHACtiO+zEoDDe7ta389qgtXxu Xz8keRJI7v6FnQzBg3nwFz20Aq8/IuvVaOrhHfwb+I8cVjYqoArTGrkQEUPAFgBmwv9/dnH4JMY r/MqDSmC/O6X3HdI7yAyRdx01wlMWfqt2AzjOGHcg== X-Google-Smtp-Source: AGHT+IHYGB0IrPJVgip7iPXtJup3tiIlZ5CBpiw9KakX41ufcIsF0KTl7xl0k6v8tANNwgYdEs9Z2w04oWX3W6G2xkg= X-Received: by 2002:a05:6122:d9f:b0:539:33cd:8c4d with SMTP id 71dfb90a1353d-53c94218014mr505562e0c.0.1756128760023; Mon, 25 Aug 2025 06:32:40 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Mihail Nikalayeu Date: Mon, 25 Aug 2025 15:32:03 +0200 X-Gm-Features: Ac12FXz1GPWKr22ItAxdJAH5O61xK1LLhAi7A-hj7JWOaDfumxaFubglxJ5KBVg Message-ID: Subject: Re: [BUG?] check_exclusion_or_unique_constraint false negative To: Amit Kapila 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 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 al= l pages with the same key under a read lock, which feels too expensive. > 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 + retry= . 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.