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 1ubP8b-000Oh8-65 for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Jul 2025 19:46:57 +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 1ubP8Z-00ClVM-9S for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Jul 2025 19:46:55 +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 1ubP8Y-00ClVC-Vh for pgsql-hackers@lists.postgresql.org; Mon, 14 Jul 2025 19:46:55 +0000 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ubP8X-007HtE-2s for pgsql-hackers@postgresql.org; Mon, 14 Jul 2025 19:46:54 +0000 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3de2b02c69eso27153145ab.1 for ; Mon, 14 Jul 2025 12:46:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752522413; x=1753127213; 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=pkeToPe3kmCtc8b1sBJkYunWOL8JlgIpn/bxDR28+6M=; b=B9nKVPd+XezftOPam9FbNm6iYRhUDrUWZS3/cjhH8IIDrGqOyK3fZMwhdebnThh6Az kcMcECWB0a5qH5myMGLAGkzH9TwftIUon9K1ygcpjvWhIzPqVvKwmj9Ho5hE+G5VopNA tkMfRwqTlV6KN0rckGeYgD+7vDLzmDcxedkCf/2sWDlfd/zgdQXyV8zlGtC6lBoHWYSG rxMj6zBvlutWusOJaUAkHV997Ukt2WF7Ggq0dNBig7612sgV0eIdnYA3KX9lEHqFcmFq b6HcrYMjF/Ivi8hiC+1G/+UHFa6I7HnwfGbydL6YAKWzl1X88fXOOS2dIDw0hnEBdlu0 FjLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752522413; x=1753127213; 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=pkeToPe3kmCtc8b1sBJkYunWOL8JlgIpn/bxDR28+6M=; b=LV+nTZ496muRoIncXcDTxYCD+sj2puCawWnyIjnEzwydgjAIQ4cDVN5Wu1MtYS34o8 mywtGzKfWMwmAH5TnO7lxPT+GfH7Qd0SUlIavPkGDaJr9qUscVpVajv8JXaGPngix74N zfTjjJmbN/RLoPpLnXx8ts4tqtzX+tf55vAveTTZ/4nIu1NA3nqmSBIUy0jgUBrH2EWp JOwGe5/whj66BKm0CnhcUp866ZMV1A9UP0/XOp7k/56aVE+PPRGIp5jAvU+LnvV3HC51 hAgMVMXLMF4rStVCzWSWruf0pnY17E7Cd1Qs7qumHfV5oHdr0PtexsbpPWGFEP9nrzwL mduw== X-Forwarded-Encrypted: i=1; AJvYcCWVt40mu3nsh0yBUB4+1IsxxlfV+3vEyuZCYQ0xVv1mDr2AKMrYpHpuUxI33uYT+NN/9l1uq0lqEhehZQA2@postgresql.org X-Gm-Message-State: AOJu0Yw0uzWA06Ec3HybqNTudM0a8H7DAVW5o5D7OLEnnbMNweyxm64d 66M3d/ineXioGVYkU6nBuIeBczfzx3Fx2HmVOqO92XBQRVgoKqnFn0EN X-Gm-Gg: ASbGnctv+SNV+3UeNIa49f9JDsvwFpa4MfNGYAN/WrDeMkJWabTVuPBwViQnua1CVE8 JAgVunr5QzzWiA6XoGNUmTSExkDXe4i4r/40NDpfJaTMyWe3LfGF8U6z//TjuHJkAQCePdIcz7k mDMXNCUBNxp2Ax+xycCjJao5lnsZnMY2PKfVDBD4idyY34nKTwWd3WnCFR+gftVpmyLkQPfh/uy 9ke8mE9cuuv/QxUyL7Nj6AidlPM9Gu5IXA794cIH4Q0XBBgnLlfwHOKTEofjXj5jlPO1GYPqW63 xFRcfEZcVwBIS/7V7bS71qQIrDjiDtS/eLtS4e942E71elubNYcyiJYe0f9iRX6qify9HUe0dcZ 5q6o11eElPQptz7bfKCe2XynKbHaN1S8Wj+Ymvov5waI2MO4K2F0dZuNKbhl4+VxuK9DiQhsYn0 4TpNfyN2d/X/QD X-Google-Smtp-Source: AGHT+IEfIFyoKV5emHRz3/PveMcZsm4O/2f0ErxqCK5n8afvvYnx4aDrmM/JsYU8TCsPChRji8/T+A== X-Received: by 2002:a05:6e02:3f13:b0:3d9:65b6:d4db with SMTP id e9e14a558f8ab-3e2542f9baamr179249195ab.12.1752522413005; Mon, 14 Jul 2025 12:46:53 -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-505565e5193sm2227752173.57.2025.07.14.12.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Jul 2025 12:46:52 -0700 (PDT) Date: Mon, 14 Jul 2025 14:46:50 -0500 From: Nathan Bossart To: Sami Imseih Cc: Bertrand Drouvot , 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, Jul 14, 2025 at 02:34:00PM -0500, Sami Imseih wrote: >> Why do we need three different places for the lock names? Is there a >> reason we can't put it all in shared memory? > > The real reason I felt it was better to keep three separate locations is that > it allows for a clear separation between user-defined tranches registered > during postmaster startup and those registered during a normal backend. The > tranches registered during postmaster are inherited by the backend via > fork() (or EXEC_BACKEND), and therefore, the dshash table will only be used > by a normal backend. > > Since DSM is not available during postmaster, if we were to create a DSA > segment in place, similar to what's done in StatsShmemInit(), we would also > need to ensure that the initial shared memory is sized appropriately. This is > because it would need to be large enough to accommodate all user-defined > tranches registered during postmaster, without having to rely on new > dsm segments. > From my experimentation, this sizing is not as straightforward as simply > calculating # of tranches * size of a tranche entry. > > I still think we should create the dsa during postmaster, as we do with > StatsShmemInit, but it would be better if postmaster keeps its hands off this > dshash and only normal backends can use them. Ah, I missed the problem with postmaster. Could we have the first backend that needs to access the table be responsible for creating it and populating it with the built-in/requested-at-startup entries? Also, is there any chance that postmaster might need to access the tranche names? -- nathan