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.96) (envelope-from ) id 1w0SgI-001vS9-2n for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 23:09:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0SgE-00CTfq-39 for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 23:09:31 +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.96) (envelope-from ) id 1w0SgE-00CTfh-2A for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2026 23:09:31 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w0SgD-00000001gSA-0F3g for pgsql-hackers@postgresql.org; Wed, 11 Mar 2026 23:09:30 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id A3A2D7A0265; Wed, 11 Mar 2026 19:09:27 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Wed, 11 Mar 2026 19:09:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1773270567; x=1773356967; bh=F7uzBXh7e0 wl3YexwKZMUuw2Y2SF1JdsCMkHRleCpHo=; b=K/W4r4BK3j2Vba/kVXgMrChHD1 Bnp4OatCRAJja5myLj96CN9zZEOoHM6m8T8NhvEmR2s+CTiC2Ll5aX6I+jEqt+u9 1VhiSuv2bBHzhR30iWfAiYRS2z5HXh2x23ineTv6U90v8SkWFmJICwoSWg6GUAqF KjRoA34XqVU8qkymq0ihxP6IZq6aDSmb4mw2yJqnlV+TWO7QGIVbm+fXWkssmmqY qJhQwEw4qzwb7kmC+lcC3d5nm8YDafemFZZ1VEzGCDZXtFd74mHX22bTvLLLgB5T i/LF/mJU1dv2p2wWj+hPDimmvsePdZ28MSOkJ7bv8mbpbqjpcqzixyXJF5ZQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1773270567; x=1773356967; bh=F7uzBXh7e0wl3YexwKZMUuw2Y2SF1JdsCMk HRleCpHo=; b=i8QXA0/srCs2sFh4WuP6dY4HVc2jieEWaR7vqFsmlj1cr0KDVH6 PV3G6CUUP4NGe3A6eR1bx95tfQXMSLyX6ApiVSW6ZvElNdPNCfMbyl+z769ocwhh BcF/GEEUE7vhDtSFuhokw6wrE7S8YdnrWNPlMQVpW9MwJBIrhygVq1Gkrk5N9iBu eX3zbaqWgYiuiiUpwhYK+QqXk/2gcyY1+Mi1VflJFQ6LgGGxXggO27+0eIPB96qw jBImFTnRKKLyMY820CO60qT1vppHBLsgtMCJ8zo4wG3N2ZWLBwM0z3MKmg+g8vtJ rt38enmyuQfER+xvZoW0NI4RDpGS5rAHKJQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeehudekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtsfdttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepfeffgfelvdffgedtveelgfdtgefghfdvkefggeetieevjeekteduleevjefh ueegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopedutddpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtoheprghhsegthigsvghrthgvtgdrrghtpdhrtghpth htohepsghovghkvgifuhhrmhdophhoshhtghhrvghssehgmhgrihhlrdgtohhmpdhrtghp thhtohepmhgvlhgrnhhivghplhgrghgvmhgrnhesghhmrghilhdrtghomhdprhgtphhtth hopehmihgthhgrvghlrdhprghquhhivghrsehgmhgrihhlrdgtohhmpdhrtghpthhtohep rhgvshhhkhgvkhhirhhilhhlsehgmhgrihhlrdgtohhmpdhrtghpthhtoheprhhosggvrh htmhhhrggrshesghhmrghilhdrtghomhdprhgtphhtthhopehthhhomhgrshdrmhhunhhr ohesghhmrghilhdrtghomhdprhgtphhtthhopehhlhhinhhnrghkrgesihhkihdrfhhipd hrtghpthhtohepnhhorghhsehlvggruggsohgrthdrtghomh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 11 Mar 2026 19:09:26 -0400 (EDT) Date: Wed, 11 Mar 2026 19:09:26 -0400 From: Andres Freund To: Antonin Houska Cc: Kirill Reshke , Heikki Linnakangas , Melanie Plageman , Matthias van de Meent , pgsql-hackers@postgresql.org, Thomas Munro , Noah Misch , Robert Haas , Michael Paquier Subject: Re: Buffer locking is special (hints, checksums, AIO writes) Message-ID: References: <4csodkvvfbfloxxjlkgsnl2lgfv2mtzdl7phqzd4jxjadxm4o5@usw7feyb5bzf> <61812.1770637345@localhost> <19720.1770709587@localhost> <196082.1770892568@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <196082.1770892568@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-02-12 11:36:08 +0100, Antonin Houska wrote: > Andres Freund wrote: > > > For something committable, I think we should probably split IsMVCCSnapshot > > into IsMVCCSnapshot(), just accepting SNAPSHOT_MVCC, and IsMVCCLikeSnapshot() > > accepting both SNAPSHOT_MVCC and SNAPSHOT_HISTORIC_MVCC. And then go through > > all the existing callers of IsMVCCSnapshot() - only about half should stay > > as-is, I think. > > The attached patch tries to do that. Thanks! > From dcdbaf3095e632a1f7f65f3abc43eccff0249d4c Mon Sep 17 00:00:00 2001 > From: Antonin Houska > Date: Thu, 12 Feb 2026 11:14:00 +0100 > Subject: [PATCH] Refine checking of snapshot type. > > It appears to be confusing if IsMVCCSnapshot() evaluates to true for both > "regular" and "historic" MVCC snapshot. This patch restricts the meaning of > the macro to the "regular" MVCC snapshot, and introduces a new macro > IsMVCCLikeSnapshot() to recognize both types. > > IsMVCCLikeSnapshot() is only used in functions that can (supposedly) be called > during logical decoding. I think I agree with where you selected IsMVCCSnapshot() and where you selected IsMVCCLikeSnapshot(). > diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h > index b8c01a291a1..dd5aaae6953 100644 > --- a/src/include/utils/snapmgr.h > +++ b/src/include/utils/snapmgr.h > @@ -53,12 +53,14 @@ extern PGDLLIMPORT SnapshotData SnapshotToastData; > > /* This macro encodes the knowledge of which snapshots are MVCC-safe */ > #define IsMVCCSnapshot(snapshot) \ > - ((snapshot)->snapshot_type == SNAPSHOT_MVCC || \ > - (snapshot)->snapshot_type == SNAPSHOT_HISTORIC_MVCC) > + ((snapshot)->snapshot_type == SNAPSHOT_MVCC) > > #define IsHistoricMVCCSnapshot(snapshot) \ > ((snapshot)->snapshot_type == SNAPSHOT_HISTORIC_MVCC) > > +#define IsMVCCLikeSnapshot(snapshot) \ > + (IsMVCCSnapshot(snapshot) || IsHistoricMVCCSnapshot(snapshot)) > + > extern Snapshot GetTransactionSnapshot(void); > extern Snapshot GetLatestSnapshot(void); > extern void SnapshotSetCommandId(CommandId curcid); Probably need to update the comments a bit. What about something like /* * Is the snapshot implemented as an MVCC snapshot (i.e. it uses * SNAPSHOT_MVCC). If so, there will be at most be one visible row in a chain * of updated tuples, and each visible tuple will be seen exactly once. */ #define IsMVCCSnapshot(snapshot) \ ... /* * Is the snapshot either an MVCC snapshot or has equivalent visibility * semantics (see IsMVCCSnapshot()). */ #define IsMVCCLikeSnapshot(snapshot) \ Greetings, Andres Freund