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 1uaLEH-0041wK-CN for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Jul 2025 21:24:25 +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 1uaLEF-007EXm-3I for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Jul 2025 21:24:23 +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 1uaLEE-007EXe-Mu for pgsql-hackers@lists.postgresql.org; Fri, 11 Jul 2025 21:24:23 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uaLED-006pA7-25 for pgsql-hackers@postgresql.org; Fri, 11 Jul 2025 21:24:22 +0000 Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-3e25355160dso5124955ab.0 for ; Fri, 11 Jul 2025 14:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752269060; x=1752873860; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=GauHnkqg5sDdTsyy5Xg4aTFZZlq4ubSkt64THYNWnS0=; b=ZduBKMlu5BCMLq20BoRXueuk0DCC+D3pAlDXVGERy3277J9XP6J3pvj0twcVbJBqUX WfZH7X/Fse6wIX+Kk82wMOmX3KVRo3dju6liP/pQvaR5Y8DbLWwZVOvLqX3f0zCHM3KV XP6UJMELms4zsea3JTF1V8fOwrckVZXfcBd/wqTe0ZYIrOU6n76QDo7RYiaYWcuGu/cA ZqY3UvEKzg/SGwcA3AZ5Tt8gdCMMUA3s+QRfCEZx8wGkqB+fhLs1QMjxUnf5z2rAhGdD Uhx1NvkaMkBmeWzibS16GpIWGCYlwj8lazTgRSNu0+8xPLvrAanTuN7PpBvcNkUDnChl nM9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752269060; x=1752873860; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=GauHnkqg5sDdTsyy5Xg4aTFZZlq4ubSkt64THYNWnS0=; b=q/6MYrL9yuePqo2VrRMBptLz2H8o8ITpFCjnFfilPNGovfUyTP8CgTxGB922D7r1r/ 9mwFupMn3l5kjKCnIYAULe6gE4vvXlVaMyOEB6nML6/2es3KHJS58Y61RNhxOj6+QMAQ 0EzI1on9SzNpeo21DlJhoKre8X9m43Ntp9mVyO7bJHRh5FOkPNrl5OVZn81Kn4pqkKm7 g5/aCqJDwwRYGZ2C9JVTCE0OxGOmJYFY87kr4xvGWGg6WZiBFCjtoBLmBSDvImwBD501 UsUu44NqfEsWvotRs8jRTodavSF3i5wS6qR0+00GXpdS/m3SZyiHLO8LeI5AJzpz5NTG yG0w== X-Gm-Message-State: AOJu0YyLWGVeM7G18Nx0cbGPlvV3NF/jqZPU5fn4dqYskU9r0sqSEUNW P0ZbCzChvnLz2nxvPXzI5sBPpsP9w8LeC4iCuMbXarj84HBQCdzXpqig X-Gm-Gg: ASbGncuCBJmzhwng6QpqMU754aNIt1RQ/tlX7uVFYaGVSgrx00RDHOssYMq1Z4YQHUn dQJa30eJHgRlEudhXcA4ufcB31+bD9qEwAt6PN7T9o140Ohq2b3q/NF6uMY3YACUkP0fJAUYisH ffTNxiIppMKQ1l3BA9MrK3PeWzYI8/HgKrQWGOScxouWqdiUeeSZrMPfzF28/NIKDj8kREKgep4 4qeqnGVLwZIbNTAF7vGr9I4kMGVmmf/wGiawxEAEV6tjMnZOGGZFLCw39JmSbwP5J9LOOnU+v2O H4QYiBwU8K5YfRSOujWJQRgYgLo8udH8pspkjJHEXEBgz2D+0M44O5D861EyQDEIpnyZyFQyUw1 rHlB3a6EXAD0eOFM3fxAfAlMK5F7une3UAlXpNmjWT6E0Wi34QkcLrZLxLHhq49ITdYd3yPLe4b 1KgVx3/QKh/4zF X-Google-Smtp-Source: AGHT+IEz9iqkXqPluSfp+3/UA/u+mqgHnuwq49B5ZU1DAGoRiybz29Ddi3WGIbXE3G4dZR8cDLlyZQ== X-Received: by 2002:a05:6e02:1544:b0:3dc:8b29:30b1 with SMTP id e9e14a558f8ab-3e2533103e1mr62464595ab.14.1752269060516; Fri, 11 Jul 2025 14:24:20 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-50556532442sm990564173.18.2025.07.11.14.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jul 2025 14:24:19 -0700 (PDT) Date: Fri, 11 Jul 2025 16:24:18 -0500 From: Nathan Bossart To: Sami Imseih Cc: pgsql-hackers Subject: Re: Improve LWLock tranche name visibility across backends Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jul 09, 2025 at 04:39:48PM -0500, Sami Imseih wrote: > Attached is a proof of concept that does not alter the > LWLockRegisterTranche API. IMHO we should consider modifying the API, because right now you have to call LWLockRegisterTranche() in each backend. Why not accept the name as an argument for LWLockNewTrancheId() and only require it to be called once during your shared memory initialization? In any case, a lot of existing code will continue to call it in each backend unless the API changes. > Instead, it detects when a registration is > performed by a normal backend and stores the tranche name in shared memory, > using a dshash keyed by tranche ID. Tranche name lookup now proceeds in > the order of built-in names, the local list, and finally the shared memory. > The fallback name "extension" can still be returned if an extension does > not register a tranche. Why do we need three different places for the lock names? Is there a reason we can't put it all in shared memory? > 1/ There is currently no mechanism for deleting entries. I am not sure whether > this is a concern, since the size of the table would grow only with the > number of extensions and the number of LWLocks they initialize, which is > typically small. That said, others may have different thoughts on this. I don't see any strong reason to allow deletion unless we started to reclaim tranche IDs, and I don't see any strong reason for that, either. > 2/ What is the appropriate size limit for a tranche name. The work done > in [0] caps the tranche name to 128 bytes for the dshash tranche, and > 128 bytes + length of " DSA" suffix for the dsa tranche. Also, the > existing RequestNamedLWLockTranche caps the name to NAMEDATALEN. Currently, > LWLockRegisterTranche does not have a limit on the tranche name. I wonder > if we also need to take care of this and implement some common limit that > applies to tranch names regardless of how they're created? Do we need to set a limit? If we're using a DSA and dshash, we could let folks use arbitrary long tranche names, right? The reason for the limit in the DSM registry is because the name is used as the key for the dshash table. -- nathan