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 1w9Q64-001Q0u-0v for pgsql-hackers@arkaria.postgresql.org; Sun, 05 Apr 2026 16:13: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 1w9Q61-003p4t-1X for pgsql-hackers@arkaria.postgresql.org; Sun, 05 Apr 2026 16:13:09 +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 1w9Q61-003p4k-0a for pgsql-hackers@lists.postgresql.org; Sun, 05 Apr 2026 16:13:09 +0000 Received: from lahtoruutu.iki.fi ([185.185.170.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 1w9Q5y-00000000kdy-3AcC for pgsql-hackers@postgresql.org; Sun, 05 Apr 2026 16:13:08 +0000 Received: from [10.0.2.15] (unknown [130.41.208.1]) (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 4fpcv16RNGz49Q1q; Sun, 05 Apr 2026 19:13:01 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1775405582; 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=zICAyPery70DZgCQzevpl29e7HcKJ8Llw+i/SRZ4yAc=; b=TQ7gdKi+gjYPOMUaJhCvoV2pT792hallg6Lm3SBDJx8sDAhpj64IT/QaPv3NvK4YlpPPEz 6aEdqiwyinENN2R3kz5pz2LYDPbODkMvbN4yd28/VLhY1d1fAjmFERbXgHMD+Dv8jx481v dV6oJg0nEZRHFrDk3E0u/JZbTS7yJ/rII65bxLH1T4jHF8pP55WYVFGxb+nnsECprLvkJt CrgHKrnEN78AUb+VTiK7Iz8R5FaWM9pXx6spHk5ey/XcSnsnte36A1UhkpgcEaQ/BaOxog ibFJsZQ6kLGGBya+gYLbUcJhxCErARQF0CR14zWE6ZFtE6NoZYNx+YuPvPgNqg== ARC-Seal: i=1; a=rsa-sha256; d=iki.fi; s=lahtoruutu; cv=none; t=1775405582; b=XmBAvFVxnTMnVj9iaY9yTFrMmSRWke7G5OlvEmEFSVBsTJth66rhiuxIWsus10Rx9Wc3iK RjjT+QxWjSBgJQ9UPTyCwpYmceG3bgdrA+g2ZXA9JlXypnwdZ25K8gAh0sXk5S+7C1qvaK R3fOxbnp+yUHn7yBHTUYNqxwELeGGhRs+8vzi84rUvzn6H912u3VySgZEqhsDbtzZJJr/J gSSdgmXCk/jxv7u1JPbeQaQV2naPTS+uWPRv6zUsQsHhAMA8msxoFRFHza6MZMeq7cOVoU oq2MK2MMNR29U9lgK/fu6g0EtpQwwL3QM6O6Ng6QZJNtwibAM/riB/Gj+WtNPQ== 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=1775405582; 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=zICAyPery70DZgCQzevpl29e7HcKJ8Llw+i/SRZ4yAc=; b=A438Rb4y5WC8vgnVWo+tsuGSBXVoW9e3eFFiuiPeeMw1q1Ml67af+cewhob6zX56A+jEm9 pMv9VyuSm1KUI2TX9OWYGozhizHXAp7vfs+t2nbOg2dXDO6naVlnm2m2pf+fX/V13VpXsr 0DFrgreutRLHKlBB8PRH1j6mpzwWvOJOiI6+9sB1v5KxuSpCr3xU/fmE9Z6v+0ll/q98Wv 71EtWkISaFlBbxS/2VK98vze58wqRTkma1ruzsWVLIPQbL5gDTKBUA/cDy4OkJMgkfihqu A9KIfMWZCOeBxQvcOaQgYhqLyS7uYXZos3413/7mp4BUuCZkrFuh/K6qv5t+MQ== Message-ID: <1494c82a-6f8a-449d-a90b-cd96d9b47be5@iki.fi> Date: Sun, 5 Apr 2026 19:13:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Better shared data structure management and resizable shared data structures To: Daniel Gustafsson Cc: Robert Haas , Ashutosh Bapat , Andres Freund , PostgreSQL Hackers , chaturvedipalak1911@gmail.com References: <26c766d6-db0f-43d3-a618-44f8d40a3121@iki.fi> <62b8dc23-8f6a-4cac-91ff-f74bb5bc159a@iki.fi> <8a6799be-bd42-49fb-8914-856c97bb1977@iki.fi> <113724ab-0028-493f-9605-6e8570f0939f@iki.fi> <92C8000B-4EE3-44FC-ABDD-6081E0B46D17@yesql.se> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: <92C8000B-4EE3-44FC-ABDD-6081E0B46D17@yesql.se> 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 On 26/03/2026 20:31, Daniel Gustafsson wrote: >> On 22 Mar 2026, at 01:14, Heikki Linnakangas wrote: >> * The request_fn callback is called in postmaster startup, at the same stage as the old shmem_request callback was. But in EXEC_BACKEND mode, it's *also* called in each backend. > > Should the request_fn be told, via an argument, from where it is called? It > can be figured out but it's cleaner if all implementations will do it in the > same way. I don't have a direct case in mind where it would be needed, but I > was recently digging into SSL passphrase reloading which has failure cases > precisely becasue of this so am thinking out loud to avoid similar problems > here. Hmm, you mean adding an argument along the lines of: static void pgss_shmem_request(void *arg, bool attaching) { ... } Perhaps. The idea is that a request callback should generally do the exact same thing whether it's called from postmaster or from backend startup, though. I worry that an argument like that makes it too tempting to have different logic. That said, there are a couple of places where I'm using IsUnderPostmaster for that purpose. For example, I have this in lwlock.c (in latest version I'm currently working on that I haven't posted yet): /* Size of MainLWLockArray. Only valid in postmaster. */ static int num_main_array_locks; /* * Request shmem space for user-defined tranches and the main LWLock array. */ static void LWLockShmemRequest(void *arg) { size_t size; /* Space for user-defined tranches */ ShmemRequestStruct(.name = "LWLock tranches", .size = sizeof(LWLockTrancheShmemData), .ptr = (void **) &LWLockTranches, ); /* Space for the LWLock array */ if (!IsUnderPostmaster) { num_main_array_locks = NUM_FIXED_LWLOCKS + NumLWLocksForNamedTranches(); size = num_main_array_locks * sizeof(LWLockPadded); } else size = SHMEM_ATTACH_UNKNOWN_SIZE; ShmemRequestStruct(.name = "Main LWLock array", .size = size, .ptr = (void **) &MainLWLockArray, ); } - Heikki