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 1vIV5j-003PmQ-1e for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Nov 2025 16:50:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vIV5f-001XqY-2o for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Nov 2025 16:50:03 +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 1vIV5f-001XqQ-1n for pgsql-hackers@lists.postgresql.org; Mon, 10 Nov 2025 16:50:03 +0000 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vIV5e-006PBu-03 for pgsql-hackers@postgresql.org; Mon, 10 Nov 2025 16:50:02 +0000 Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-940d327df21so81747639f.1 for ; Mon, 10 Nov 2025 08:50:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762793401; x=1763398201; 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=4Qi9C4PYBX9TJAXZWfy0oxzInoI18Q7ySb1V1dPJQ5g=; b=KxoOwW9kuvhzgVsEarhbIZ4gTGOi4uk8C7DF8RKBdW+h62WAgz5QFjIPvsXXkaEVrU nbRmIXYV1wihN7dkN9ejiLcIq7W2gkqrAgCD6HkVQxbfLDezG03dEyZM+jIHChrWXbkC 3mTZ0CnUdx0jXG82ppcBB5rBCQNn4H4X9DBeK01TRR3DcQsxN1kZVgPlPARvAQnf8l40 /x1ZgUMCC368A69B2RAOkGp8uBnDL7hhuZMgLhd4K1cVoR+qv5kU7wmnJ7zl5EIagSMr +FyjAHzRbsccgXq3mW1L3UvvnHQr8RDTrsFg9JNQqa7wFuEfsgEpap/gpF60xgEFHJpq lT5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762793401; x=1763398201; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4Qi9C4PYBX9TJAXZWfy0oxzInoI18Q7ySb1V1dPJQ5g=; b=Yb00V4+ve2MbGZNVAnqAV5kbCpVPWlBSOLwCNncZRy0PWooOYLEe6axse6CuereuEl B0vq7k8GIY67tKFEyTePOsLAxB1rpp+y1J8n2Z0Pu8B27iZSRPDH6tW5jgMxohCc5kyY 66bBRN8k3YBVjwRb39V/cjrRVt+JZoND1kzDEoSaRola6Nxq5y6kLBM+gS5eM3BZRImp N7feV32oxiqVvQ2BPOR9rqc/7xM+8voYxQiBejjWcxCpexy72zBMrJxSTN0foxFm3Ls3 yt6LsqvLiq2pUjnFwdLXCadyHlMi4OCRHm537/B10d8jJl0OY8khT2OzAajz+n5m5pGz DY9g== X-Forwarded-Encrypted: i=1; AJvYcCWNh+tBGArwyyHXRFEcv2sWIfWY19mufKsxNn+uOO/CxPUNNt2gqoIk2TEL+VarTyYb9/qLENxp2EEgFz0/@postgresql.org X-Gm-Message-State: AOJu0YyEZAaMgVp9lxscx+lBKzrKwNVUUyygi5hYKG9qEeUOx8EyKOtf V00MeHZMcOZwd1kErO5gLLlov0fiQ6kOaR5q27GU0sVr8EaGN2Rc7aty X-Gm-Gg: ASbGncumIgTMgNnD6Wy9+Jy6XQ/WqiD04K2j6eBZMYqJKU8zyGqDYTv3HUV/prKOdQP oO5bp8diqynfYjcmUMaSwso3zRdE1vVvhwksyNoDZxMytXLYEhtuRBNJL5HVwAmnaYGH4On6AEq xxMhzV8lVpBIUl159fhbWvWLfp624dDYjixMwDx9nbfV+CZNQaJGMLua/wZGsI5pb63/vxZELCs NUkgHHlEWm2/UCBy6R3z0H5uIiUoPcZgzCWBDaxYaySrF22SQ/+uZA8YBJI1Mx3qRbpl2rHcUxq weu+alP6DcZSYEJskgOKtAN8UBwtJU9JJEkCVr+Bp9RZqB1jVShh1K0xvi8TlDluWYF9vQhRHhF 2Qb9RDDB/FHUQuYGzhelvlCubqrYurOaH7ursqLJl5JqUdYDZI2czDvLqKqVvVdXSnW1+kP24MQ DcKZxk6aEGCdrHAhIUOKXNTGI44Ya2Wxf8Yfq09FtyXBm3tdW18wXDteGhYQaPJmbMM8AaMyIcl acYAf+AYSXZsZU= X-Google-Smtp-Source: AGHT+IGUqJRF0I/a5Odk8R4YclIp6FaMyuF4gKyaQR/AaATpeds5oloJvX+3cZamPLZepSZwJmiixA== X-Received: by 2002:a05:6602:6420:b0:948:63ba:6b3 with SMTP id ca18e2360f4ac-94895f9797cmr1221242039f.5.1762793401185; Mon, 10 Nov 2025 08:50:01 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-948a2af6cf6sm175415139f.7.2025.11.10.08.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Nov 2025 08:49:59 -0800 (PST) Date: Mon, 10 Nov 2025 10:49:58 -0600 From: Nathan Bossart To: Sami Imseih Cc: Alexander Lakhin , Rahila Syed , Bertrand Drouvot , Tom Lane , Andres Freund , 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 Mon, Nov 10, 2025 at 10:26:17AM -0600, Nathan Bossart wrote: > On Mon, Nov 03, 2025 at 11:50:48AM -0600, Sami Imseih wrote: >>>> I am not sure we need to do anything about this. >>> >>> Or maybe we just avoid the tranche_id from leaking >>> in test_dsa_resowners() by making it a static variable >>> and checking if we have a valid tranche id before calling >>> LWLockNewTrancheId()? That is the proper pattern. >> >> Like the attached. > > It's probably a good idea to avoid tranche leaks, but IMHO there's room for > improvement in the DSM registry, too. IIUC the problem is that the DSM > segment is still being added to the registry and found by other backends > despite the initialization callback failing. My first instinct is that we > should keep track of whether the DSM segments/DSAs/dshash tables in the > registry have been fully initialized and to just ERROR in other backends > when attaching if they aren't. That shouldn't really happen in practice, > but it'd be good to avoid the strange errors, anyway. BTW if we really wanted to avoid leaking tranches in test_dsa, we'd need to store the ID in shared memory. Your patch helps in the case where a single backend is repeatedly calling test_dsa_resowners(), but other backends would still allocate their own tranche. I don't see a strong need to fix this on back-branches, given these functions run exactly once as part of a test, but fixing it on master seems worthwhile so that extension authors don't copy/paste this broken code. -- nathan