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 1vjoP3-004iiP-0X for pgsql-hackers@arkaria.postgresql.org; Sun, 25 Jan 2026 00:54:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vjoP1-003t8J-32 for pgsql-hackers@arkaria.postgresql.org; Sun, 25 Jan 2026 00:54: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.96) (envelope-from ) id 1vjoP1-003t8B-24 for pgsql-hackers@lists.postgresql.org; Sun, 25 Jan 2026 00:54:55 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vjoOy-0029RR-2D for pgsql-hackers@postgresql.org; Sun, 25 Jan 2026 00:54:55 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 60P0sajx3496576; Sat, 24 Jan 2026 19:54:36 -0500 From: Tom Lane To: Andres Freund cc: Alexander Lakhin , Chao Li , 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) In-reply-to: References: <58821140-0182-4FF3-9A4F-5B168DDB9243@gmail.com> <732580B4-962F-4EBD-8811-F4667D79747D@gmail.com> <934395.1768518154@sss.pgh.pa.us> <90bd2cbb-49ce-4092-9f61-5ac2ab782c94@gmail.com> <3472929.1769289107@sss.pgh.pa.us> Comments: In-reply-to Andres Freund message dated "Sat, 24 Jan 2026 18:03:00 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3496574.1769302476.1@sss.pgh.pa.us> Date: Sat, 24 Jan 2026 19:54:36 -0500 Message-ID: <3496575.1769302476@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > On 2026-01-24 16:11:47 -0500, Tom Lane wrote: >> In the case at hand I think it is probably driven by two recursion levels >> trying to acquire free space out of the same buffer. SPGist is expecting >> the lower level to fail to get the lock and then go find some free space >> elsewhere. Yeah, we could probably re-code it to get that outcome in >> another way, but why? > Regardless of the assertion, it still feels like there may be something off > here. Why is the page marked as empty in the FSM, despite actually not being > empty? Who said anything about its being empty? There's X amount of space used on the page now, the outer level is preparing to add a tuple of size Y, the inner level is looking for a place to put a tuple of size Z. As long as X+Y+Z <= 8K, there's no free-space-related reason the page wouldn't work for this. We could actually try to make it work, but that seems fragile to me: the outer level would have to be prepared for the possibility that the page changes under it despite holding exclusive lock. I think it's reasonable on complexity grounds to insist that the inner recursion level go play someplace else. regards, tom lane