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 1ur048-00GaWw-1Q for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Aug 2025 20:14:49 +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 1ur046-009mJw-Em for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Aug 2025 20:14:47 +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.94.2) (envelope-from ) id 1ur046-009mJn-4w for pgsql-hackers@lists.postgresql.org; Tue, 26 Aug 2025 20:14:46 +0000 Received: from mail-il1-x129.google.com ([2607:f8b0:4864:20::129]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ur044-0021AK-0p for pgsql-hackers@postgresql.org; Tue, 26 Aug 2025 20:14:46 +0000 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3ea8b3a64bbso37300925ab.0 for ; Tue, 26 Aug 2025 13:14:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756239282; x=1756844082; 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=s/JCuFvejtQjQmU7wWIftmc/kJME5pP1rO7GZuS31fo=; b=glDqK/J2sBgaMSZyfryKMOkYNnvx8Kxjl9giLWMGtcZw2vxcrl8Ntgogc+OjSYuXPm uL6yASUB1wlahvXZHOTXiorwRK1NVMP9T8uEZZRixNg/npa6O5f6YDTStmWq/visr+vu R92nk7P9kj+yiBQID7A29TGVub66WyOupRL6BGf2fVdMZ8IQMKISxOtsC7efNQbJ7tHf y+tkM8VLtFmrAFMR6ZtQ3DxoekbslJhzmS4KHb+CLfh86Dkn6JG5cfe+d2vZCklJzajU dUGUafK/yK5HL7KfL+zPOHIljwnFlWtif9H5bJiW3IF5AsFx5VjH9M6nPZf/58iVxZoC AddQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756239282; x=1756844082; 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=s/JCuFvejtQjQmU7wWIftmc/kJME5pP1rO7GZuS31fo=; b=Shk3P46SZyW7++6W98FE9BwvpKFtYPZojFbVB6XEWjofZUcgWoGUg+EsAudO8XSCeJ w3r5whb+otDEGZkpJXO+v3aEeLKcPOLjjfwhiY7iAW/d/gCpsLDoDurQSz6+XteABs9g dXgTCPaXdRYcLidtlpK9oJL1D+cDTHMvLzNEwP8XBRBC3OnH8sgp9T2LySWxOAMSvu6j 0dNckA3vA6dar9bKamV7VadhJ8u3+Osc88BoMAzm5AIklLQAKNM/z0ccKbLuNWJn18+h W8qVCNlcxwDpNALaa7xOAtN4CAZfvzpCGOKqOboFmP1/FAnyJjbFdP9zjyjM22zKzT54 UcSw== X-Forwarded-Encrypted: i=1; AJvYcCW4oFL1Zp74LnvKG9BjnoH/CLQp+nLicnNgtXaSxTyGfOw6CuXu1mdT2hyD7wMLDHf0C6U3hV+9nItSvm2e@postgresql.org X-Gm-Message-State: AOJu0YxiS7QWf6MfCSfW1CJgMALiDHckdrgjY400Ju/uqA54DYod0MQa I6D+RsejY/bi9fr58h9VKeIKUxTllTJfGGFb/gY+HuWTmoBav7SBV2Ra X-Gm-Gg: ASbGncshYhanyp2JkQpbn80Yy3gKssEO13eIc4GKT6GKn2FhZIOCHC0uDyusApgOhvS SonKv1MRvASNYCthpGbLnkuAeews+GOEVwnfCiq6h/EIIyBiAjltTSa9vzaKryXfIyi00GuNrJy x7SAAlE28MC1xgAahXkahrVqr84GVoU5oxECekpSDuttYN3QrD9YnKmHcjScwRQTAQnyOVBuGjb YN/LMctAjsjNC1GI8GquNNIkVTCjhcTnAHxeYFttjMtu880wRQJtu55D8yzNwGb+f1ayNr404bA AwPY5hD3fP/Fz9JtN9LzgU/BiKIyFbxyk0Tk2VcAwEqjkDWUCljfjLDiwoYK8kkfU+GslbJoFhP Mxx1X67ctsH2TjsU/Li/6tVa2wzYp/CQzUNfLMDy9vSQXQwGKM95NNH17oHULXlk5gKHlVW9Be9 z4mm4su5nv/KGa0Ce9eHg49xY= X-Google-Smtp-Source: AGHT+IHUFE4fdgvVh3DoDDBZKsEaIWyjmSuFSzY1ohdu+92Wmp150kZcU/vFI2H8YpKsxPN/GCIa8A== X-Received: by 2002:a05:6e02:1a09:b0:3ef:40ac:18ec with SMTP id e9e14a558f8ab-3ef40ac1b9fmr32283675ab.30.1756239282019; Tue, 26 Aug 2025 13:14:42 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3ea4eb2a86fsm74594355ab.39.2025.08.26.13.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Aug 2025 13:14:41 -0700 (PDT) Date: Tue, 26 Aug 2025 15:14:39 -0500 From: Nathan Bossart To: Sami Imseih Cc: Tom Lane , Andres Freund , Bertrand Drouvot , Rahila Syed , 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 Tue, Aug 26, 2025 at 02:56:22PM -0500, Sami Imseih wrote: > Here is v12 that replaces the LWLock to access the shared memory with a > ShmemLock and implements a local counter. This looks much closer to what I was imagining. /* Initialize the LWLock tranche for the DSA. */ - dsa_state->tranche = LWLockNewTrancheId(); + dsa_state->tranche = LWLockNewTrancheId(dsa_state->tranche_name); sprintf(dsa_state->tranche_name, "%s%s", name, DSMR_DSA_TRANCHE_SUFFIX); - LWLockRegisterTranche(dsa_state->tranche, dsa_state->tranche_name); /* Initialize the LWLock tranche for the dshash table. */ - dsh_state->tranche = LWLockNewTrancheId(); + dsh_state->tranche = LWLockNewTrancheId(dsh_state->tranche_name); strcpy(dsh_state->tranche_name, name); - LWLockRegisterTranche(dsh_state->tranche, dsh_state->tranche_name); We probably need to do the sprintf/strcpy before LWLockNewTrancheId(). Also, I'm thinking we should just use the same tranche for both the DSA and the dshash table [0] to evade the DSMR_DSA_TRANCHE_SUFFIX problem, i.e., those tranche names potentially require more space. + /* Space for name of each tranche. */ + size = add_size(size, mul_size(MAX_NAMED_TRANCHES, MAX_NAMED_TRANCHES)); Presumably one of the mul_size() arguments should be MAX_NAMED_TRANCHES_NAME_LEN. +NamedLWLockTrancheArray "Waiting to access the named LWLock tranches array." +PG_LWLOCK(54, NamedLWLockTrancheArray) These can be removed now, right? [0] https://postgr.es/m/aKzIg1JryN1qhNuy%40nathan -- nathan