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 1w5Xf1-003M2Z-06 for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2026 23:29:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w5Xez-00HT5Y-1W for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Mar 2026 23:29:13 +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.96) (envelope-from ) id 1w5Xez-00HT5P-0N for pgsql-hackers@lists.postgresql.org; Wed, 25 Mar 2026 23:29:13 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w5Xet-00000001A9o-2Lb4 for pgsql-hackers@lists.postgresql.org; Wed, 25 Mar 2026 23:29:12 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 0AE553E9EB; Wed, 25 Mar 2026 23:29:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vondra.me; s=gm1; t=1774481345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YasadmPfRiB1o/wNteOLyrm16b01yqH1DVR4mfRujrA=; b=LsvESejVzqOvptp81JOZKanSfjQokepxzGrbF0lOYamV1Pc4UbsP0SYck1xS051rNHNg4d z3pnpRYxpIeHgcsHryoykK9MUbsK56svfNt0cOXNqj44vly8PA+Y7phqWvMZyRUiRbhkYw rhRQtuveR1gXV+GVGaDyTSNk2Z1CfD+Tblks0twMANkzEC+mwA0TFhgaMOcDKzXDThLdpc UHpqKUBfftgKAE3kyNuj+l/AmyffIyrjV4or7xhhYdAxDCQAozm3wBZWpvmdpW8TauDcAV lHINM5QRPi4gsJ84TeFkYZPwl9lkHcdnAukC94RBzXS7N2QpKtbM/XBeDWY41w== Message-ID: Date: Thu, 26 Mar 2026 00:29:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) To: Melanie Plageman Cc: Andres Freund , Kirill Reshke , Chao Li , Andrey Borodin , Xuneng Zhou , Robert Haas , PostgreSQL Hackers , Heikki Linnakangas References: <2be31f17-5405-4de9-8d73-90ebc322f7d8@vondra.me> Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: tomas@vondra.me X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefvdehjeelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddvjeenucfhrhhomhepvfhomhgrshcugghonhgurhgruceothhomhgrshesvhhonhgurhgrrdhmvgeqnecuggftrfgrthhtvghrnhepuedvvdeifefffeekudeggfdtieeglefggeduheffveeihefggfehgfdvudetffevnecukfhppeekiedrgeelrddvfeeirddvtdegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepkeeirdegledrvdefiedrvddtgedphhgvlhhopegluddtrddufeejrddtrddvngdpmhgrihhlfhhrohhmpehtohhmrghssehvohhnughrrgdrmhgvpdhqihgupedttefgheehfefglefguedpmhhouggvpehsmhhtphhouhhtpdhnsggprhgtphhtthhopeelpdhrtghpthhtohepmhgvlhgrnhhivghplhgrghgvmhgrnhesghhmrghilhdrtghomhdprhgtphhtthhopegrnhgurhgvshesrghnrghrrgiivghlrdguvgdprhgtphhtthhopehrvghshhhkvghkihhrihhllhesghhmrghilhdrtghomhdprhgtphhtthhopehlihgvvhgrnhgthhgrohesghhmrghilhdrtghomhdprhgtphhtthhopeiggehmmhhmseihrghnuggvgidqthgvr ghmrdhruhdprhgtphhtthhopeiguhhnvghnghiihhhouhesghhmrghilhdrtghomh List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/25/26 19:54, Melanie Plageman wrote: > On Wed, Mar 25, 2026 at 2:02 PM Tomas Vondra wrote: >> >> 0002 >> >> - Don't we usually keep "flags" as the last parameter? It seems a bit >> weird that it's added in between relation and snapshot. > > In an earlier review, Andres said he disliked using flags as the last > parameter for index_beginscan() because its current last two > parameters are integers (nkeys and norderbys), which could be > confusing. Personally, I think you have to look at the function > signature before just randomly passing stuff, and so it shouldn't > matter -- but I didn't care enough to argue. If you agree with me that > they should be last, then it's two against one and I'll change it back > :) I can keep the callsite comments naming the flags parameter. > Who am I to argue with Andres? ;-) I'm kinda used to flags being the last argument, but it's not something I'm particularly attached to. >> - Do we really want to pass two sets of flags to table_beginscan_common? >> I realize it's done to ensure "users" don't use internal flags, but >> then maybe it'd be better to do that check in the places calling the >> _common? Someone adding a new caller can break this in various ways >> anyway, e.g. by setting bits in the internal flags, no? > > Yes, callers of table_beginscan_common() could pass flags they > shouldn't in internal_flags. But I was mostly trying to prevent the > case where a user picks a flag that overlaps with an internal flag, > conditionally passes it as a user flag, and then when they test for it > in their AM-specific code, they aren't actually checking if their own > flag is set. > Ah, so we expect people to invent their "own" flags, outside what's in ScanOptions? Or do I misunderstand how it works? (I admit not reading the whole massive thread, as I was only interested in using the flags in my own patch.) > Anyway, it's not hard to move: > Assert((flags & SO_INTERNAL_FLAGS) == 0); > into the table_beginscan_common() callers and then pass the internal > flags the caller wants to pass + the user specified flags to > table_beginscan_common(). And I think that fixes what you are talking > about? > Right. I wouldn't say it "fixes" it, because it wasn't a bug. But it does ensure the two sets do not "overlap", which I assume should never happen. >> If we want to have these checks, should we be more thorough? Should we >> check the internal flags only set internal flags? > > That's easy enough too. > Assert((internal_flags & ~SO_INTERNAL_FLAGS) == 0); I think does the trick. > > I think this would largely be the same as having > table_beginscan_common() callers validate that the user-passed flags > are not internal and then OR them together with the internal flags > they want to pass to table_beginscan_common(). > > I'm trying to think of cases where the two approaches would differ so > I can decide which to do. > OK -- Tomas Vondra