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 1w7J1h-005ATa-14 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 20:15:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7J1f-0069tp-24 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 Mar 2026 20:15:56 +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 1w7J1f-0069tf-0n for pgsql-hackers@lists.postgresql.org; Mon, 30 Mar 2026 20:15:55 +0000 Received: from lahtoruutu.iki.fi ([185.185.170.37]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w7J1d-00000001rQA-1hH4 for pgsql-hackers@postgresql.org; Mon, 30 Mar 2026 20:15:54 +0000 Received: from [10.0.2.15] (unknown [130.41.208.2]) (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 4fl2Ys1vBsz49PsK; Mon, 30 Mar 2026 23:15:45 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1774901746; 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=M05WYUAk5zyHt3TvxQa/+78BhfQ6R6mBd32PfXyNHSU=; b=eTAmc4E9+uobPM0+Skrsp99yZsFOmoye4Ca6Yc70GNTWCpJcA6mn2hY/jvX/i2ZsXAZbcP QEz7arZc3O1xM+elk0OYfoP7fUqDI9BY7zUXMQMz1AmoMj/zIz1MSwyhAO+GTgI7Orq7M2 MC8UjpenKUL1a9KYEH8RIY8OY6Y9IYFcTqcliVvWsZ5EylbTUWni6pT5HHdK+kPKvMQNJM xAvT7ptRTYvueJPFAE5v1o0nHMiON2ngDhJ4z6/T0c3NL++XfgUTmai8IJcPR65u9qBioi 3XqHyUdEic2oCMdN+v7qKXF9W1AAeb3PjJIZRAxsS2XXE5+H0AaLkZAvns+9qg== ARC-Seal: i=1; a=rsa-sha256; d=iki.fi; s=lahtoruutu; cv=none; t=1774901746; b=Cw4pFGSatC21AqqWvsOlJ2eAmhEvbaRjBcFtib2b0JtQUd5MEhMmAdufphVeMzFxiciJvq WcYVhdN5iDu3TofEp3kVMt1PPys8parxxnks0elIsMERihM2SQrdk6lx5jPaaOCWKfK6Vh 4Qsd2MP5h/K0WsSUy/cVFrUROEG0ZXvq+MKZFuIvQRa1bxAjbfHMxSusZEEmCYy9jAU5Cy 1FYc8MmWgxRRhTYQvVciQvlGlVNInwOYkuFn8etb8rs0+LeUL5ta7y+7G7X4AKsAtrRVWh wMfWYfHvLcaj1BDvJM/++kRBmUwK2fzvSfw6ywPc6LN7on1REbXLsfgSrLS6Vg== 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=1774901746; 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=M05WYUAk5zyHt3TvxQa/+78BhfQ6R6mBd32PfXyNHSU=; b=Tu7LWQalgpFsDgfcbamBbjgHwtLLieV4A538TZYUg6ULjB1cJy2plsUhBB3pZ5xMNR8oSU Q9kL3NMFcz+xIHA88KukGTbgH5i2pNSNRxDCf8kctv0l/aUbZMD6IlkZAHatr2EvyZGzrF KWLzl/rynRIGaMvXto25cyJehhF5iQ6bZOJ5NOpIqnECcUwq+JxpoD/bwS1tbEdXTzblRS 8xLEv3QIHnHfrHxhhvyvYEHpOly/Kxj/iQM102Gb8UL2KhACe2y2I2dA88CoSj8/EjP74F Q9HBRhyr04xpSRgfZ1o2dt47H2PeCuq3UFiBkmI0go8xIDJLCDUM0rrkZeVYnA== Message-ID: <791c3f18-f4de-4d84-ac6b-c7ccc074dd38@iki.fi> Date: Mon, 30 Mar 2026 23:15:44 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Better shared data structure management and resizable shared data structures To: Ashutosh Bapat Cc: Robert Haas , Andres Freund , pgsql-hackers , chaturvedipalak1911@gmail.com References: <8a6799be-bd42-49fb-8914-856c97bb1977@iki.fi> <113724ab-0028-493f-9605-6e8570f0939f@iki.fi> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 30/03/2026 07:50, Ashutosh Bapat wrote: > On Sat, Mar 28, 2026 at 4:47 AM Heikki Linnakangas wrote: >> On 27/03/2026 09:01, Ashutosh Bapat wrote: >>> /* Restore basic shared memory pointers */ >>> if (UsedShmemSegAddr != NULL) >>> + { >>> InitShmemAllocator(UsedShmemSegAddr); >>> + ShmemCallRequestCallbacks(); >>> >>> It's not clear how we keep the list of registered callbacks across the >>> backends and also after restart in-sync. How do we make sure that the >>> callbacks registered at this time are the same callbacks registered >>> before creating the shared memory? How do we make sure that the >>> callbacks registered after the startup are also registered after >>> restart? >> >> On Unix systems, the registered callbacks are inherited by fork(), and >> also survive over crash restart. With EXEC_BACKEND, the assumption is >> that calling a library's _PG_init() function will register the same >> callbacks every time. We make the same assumption today with the >> shmem_startup hook. > > RegisterShmemCallbacks() may be called after the startup, and it will > add new areas to the shared memory. How are those registries synced > across the backends? From your answer below, those registries are not > synced across backends. They will be wiped out by the restart and > won't be registered again. Is that right? I think we need to document > this fact and also the need to call RegisterShmemCallbacks() from all > the backends where the new areas are required after the startup. Correct. Ok, I'll add a note to comment on RegisterShmemCallbacks() to call that out more explicitly, hope it helps. - Heikki