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 1w5o28-003eDJ-1c for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2026 16:58:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w5o25-003yr8-1z for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Mar 2026 16:58:10 +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 1w5o25-003yr0-0j for pgsql-hackers@lists.postgresql.org; Thu, 26 Mar 2026 16:58:09 +0000 Received: from lahtoruutu.iki.fi ([2a0b:5c81:1c1::37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w5o23-00000001Jkd-09pY for pgsql-hackers@postgresql.org; Thu, 26 Mar 2026 16:58:09 +0000 Received: from [10.0.2.15] (unknown [137.83.235.84]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4fhVMR72kwz49Q5S; Thu, 26 Mar 2026 18:57:55 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1774544276; 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=NKF29OfnGG2N9kPt1hEGL5a1BAnflijP6ubFE8gkndg=; b=PYNrGz7QFQM7x7fd6YVrBSLI96SAGUuoxTpdGBOtjZ/H4PaNt5XlIcKEDnsJawpWLUpCyh VDj/31hURB19k8/gEy+XW4W1QjCN/1+ej5svH7UuSaz3VHf9wgmikhQ2C084VanAn62teN Z9LBxFkYn/oHG8VC57irMOCs7n7shF3revbcDO46OCuE3up8JO7VgPfGz+66KXNC/CAkdA wbz8OW9ovSYheNqS2GlnBs02ch91OOFES2x0RqNk21uB+X3aLrgd+fEtTC5bVZfYww+IZq 4LGjA5DAAsoEJgIX7WDCVkel8nbiEmXfD4LhluntsVb/U9NDuRJTGZVqG4vgLA== ARC-Seal: i=1; a=rsa-sha256; d=iki.fi; s=lahtoruutu; cv=none; t=1774544276; b=P2Dc9frileizbQ6GQNvKpsTIp6nNQ8f5yLg6UTvohnAmfNLLYH+8sTVbxxnOeKzJ2wmGD1 g0rPhzQ7h6jCXyozczV4p+hYmZbp4NBaO4qZo/yxOEEPQkuAwTN7/ibg/CMgsShvN1j5Y4 Xymo63w4pe9efgkqlIC5KkYXhb2dWA9dw+Gj57rg5rW2JCigyu7pn0qnQJmsprnNmny++7 S/EJUkBU176un5gOnvrAkP8PytXLTTOayKclQuLjfipbEmuROg8g35ciXr3yPFAdAtwLWN DsCJRc+d5MbKqiz46Xe6Yrmltml3o9xjnnDR2hBQ9qAmLXcNWXkKXQm4lWUQMQ== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1774544276; 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=NKF29OfnGG2N9kPt1hEGL5a1BAnflijP6ubFE8gkndg=; b=tAY3npIor0I6RQBBbz6lbym6I24x0vKFKq35adm1Kc5geG/TZaOJIUAQ/70X3z8hjePsXg qy3/otxWx6cPXqFaoeA1AB1igIZ5CR8WBwwjBnTn7cAkRZjxz6qHmVO6V8zAHhNtemOykt o9ytwrznD2GozEl70xtI8uph6M2VZt8fRDwY+VF4r7Gk8C4vJBzhoo31e8IMfKTSfI63mT GMn+iGZuEnIC2YPRDp9TnI4H6h6LIOQlMu0sAHNE0b+D8PvIA3pp891JrTDRqOsU41Hs0q HFX9/nf9Qu7Um+C+/DZkgkItea2xam0eBCQvep8YXlbIUuC+BNyI2YRGmw/BHA== Message-ID: Date: Thu, 26 Mar 2026 18:57:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Clean up NamedLWLockTranche stuff To: Sami Imseih Cc: Nathan Bossart , Robert Haas , "pgsql-hackers@postgresql.org" References: <47aaf57e-1b7b-4e12-bda2-0316081ff50e@iki.fi> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks! On 26/03/2026 18:34, Sami Imseih wrote: >> I propose the attached refactorings to make this less confusing. See >> commit messages for details. > > I only took a look at 0001 so far, and I do agree with this statement > in the commit message: > > "The "user defined" term was already used in LWTRANCHE_FIRST_USER_DEFINED, > so let's standardize on that to mean tranches allocated with either > RequestNamedLWLockTranche() or LWLockNewTrancheId()." > > I do wonder if 0001 is going far enough though. > > Instead of just standardizing that "user defined" could mean tranches allocated > with RequestNamedLWLockTranche() or LWLockNewTrancheId(), how about we also > rename these APIs to reflect that as well? This way we remove all concept of > "named tranche" which is what it sounds like to me you are proposing. > > rename RequestNamedLWLockTranche() to RequestUserDefinedLWLockTranche() > and LWLockNewTrancheId() to RegisterUserDefinedLWLockTranche() I'd rather not change RequestNamedLWLockTranche(), because I think LWLockNewTrancheId() is better and should be used in new code. I consider RequestNamedLWLockTranche() to be a legacy function, for backwards compatibility. > RequestNamedLWLockTranche() requests the lwlock at shmem_request time, > which is later registered via LWLockNewTrancheId() when lwlocks are > initialized by the postmaster. > > Also, the name LWLockNewTrancheId() is selling what this function does > too short. > It does return a new tranche ID, but it also takes in a user-defined tranche > name and copies ("registers") that name into LWLockTrancheNames. > > v19 is already changing the signature of LWLockNewTrancheId(), so maybe > improving the names of these APIs makes sense to do. Oh, I didn't realize we changed the LWLockNewTrancheId() signature! Yeah, if we're changing it anyway, we might as well rename it. I'm not sure if I like RegisterUserDefinedLWLockTranche() better, but let's think it through. - Heikki