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 1vlYZI-000gyI-2y for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jan 2026 20:24:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vlYZG-000kcu-01 for pgsql-hackers@arkaria.postgresql.org; Thu, 29 Jan 2026 20:24: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.96) (envelope-from ) id 1vlYZF-000kcj-2G for pgsql-hackers@lists.postgresql.org; Thu, 29 Jan 2026 20:24:42 +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 1vlYZE-0001Hc-0Z for pgsql-hackers@postgresql.org; Thu, 29 Jan 2026 20:24:41 +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 60TKONpt1264181; Thu, 29 Jan 2026 15:24:23 -0500 From: Tom Lane To: Andres Freund cc: Peter Geoghegan , 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> <3496575.1769302476@sss.pgh.pa.us> Comments: In-reply-to Andres Freund message dated "Thu, 29 Jan 2026 12:27:10 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1264179.1769718263.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 29 Jan 2026 15:24:23 -0500 Message-ID: <1264180.1769718263@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > Anyway, independent of that, the behavior clearly needs to be allowed. H= ere's > a proposed patch. > At first I was thinking of just removing the assertion without anything = else > in place - but I think that's not quite right: We could e.g. be trying t= o > acquire a share or share-exclusive lock when holding a share lock (or th= e > reverse), but we can't currently don't keep track of two different lock = modes > for the same lock. Therefore it seems safer to just define it so that > acquiring a conditional lock on a buffer that is already locked by us wi= ll > always fail, regardless of what existing lock mode we already hold. I t= hink > all current callers good with that. > Does that sound reasonable? I didn't read the patch, but I agree with this description of what the behavior should be. > We could add support for locking the same buffer multiple times, but I d= on't > think it'd be worth the complexity and (small) overhead that would bring= with > it? Also agreed --- I think that's behavior we actively don't want. > It also seems like allowing that would make it more likely for a backend > to trample over its own state higher up in the call tree. Precisely. regards, tom lane