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 1w0lD6-002BS1-28 for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Mar 2026 18:56:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0lD2-00GiHK-1i for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Mar 2026 18:56:37 +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 1w0lD2-00GiHC-0m for pgsql-hackers@lists.postgresql.org; Thu, 12 Mar 2026 18:56:36 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w0lD0-00000002LLE-0Q8R for pgsql-hackers@postgresql.org; Thu, 12 Mar 2026 18:56:36 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b943a880577so184336566b.3 for ; Thu, 12 Mar 2026 11:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773341792; cv=none; d=google.com; s=arc-20240605; b=B1cGOG9QXY25bpQ6x1gWrWIJN5wBrTPHnkemUz6GyiiQb/2kRI+3UB6eQeItr9yXc3 xJuDhm5WQNSObcIUhjHugd0mJl79Mfl1ev51nzDhwgPz2hlRIyzkLO7grLKEuU1WcUPb 79AMHoKsaxeT6r6BB2G3Voqot3DoeeFu7kHq9nHhlcPZFBMgF+pWkScy4NyMv66nMGeB PUgR5sYYwre0msVE8TeY0uRBHrFj+By/K7OLSpII4etWqeAg1ezCp90uH5cvQRF5F35I dZQgHw+x96upv0mYXN6VEbslj34jVefXRKZYRLPEZn1hhhhLs0BghBs6LRE+gtG5Y10y 60AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=K37CCclDFVHdKBYU3e8Fujk7zsuA6CY18RMwRlfjOaY=; fh=J6u88ghAqG4kw43RYeqK6C6kuXblewck3f5ChGCJM6o=; b=Hy1nEdb3Iu7sSjpwQ2EKGsYKQD5lhJIM14Q+l2Nd9CN4P0jUz9g0ZqfsUmeL/9HO4H ZTxu13Zd+vOyXn0K1PTPbnweKtpvi92WPd12BnEMkVMbd95NzzfUa/ihDdehhp14Ra5p Q9/RXuCFtbGZabaktY5hlpviS56A5E5tFdWdIgebnqGb3Bmni9UoNMKpbqvlbTRDkFdq VXgANvNGqE3WYzDs5qDQK+sSLMiLcjnMIIfzLMF7ks65AOrM83FnFOUgwrHPlmswQo89 Gz84GsUgV+BpbiD91SDdi+GBRU+WRMr2cFz99zJhI1L6LiHIwA7ZFmmoyqx9u3L2eSIG u1Wg==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773341792; x=1773946592; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=K37CCclDFVHdKBYU3e8Fujk7zsuA6CY18RMwRlfjOaY=; b=jBzEkpHIh9c8OvgMbhFS1HL35Qs2TJ43VbsSH6AvviGHDVbdETibwzrMaz8KXy1B5t OFmKrD63iuriD0zuLpXua4HGwaDiFEbdBuopIq+EbdtuAt+DAKO50Vv2cEL7u2AB7Hq9 wppsEiwyutKpGcs9HBjPAn23zN96DkdHnnzhmewUQ1UYRKA1iwW20kdufbFeq+dV50aY uyQAPYgpD/qh+BG06XP53gpP0beXABbdLv6bL7xdyu3UjHUeG7mlfPPYEtQzNdGjRcOb UcCaEgK/b/vfLywuYUV5dfDJ8V61DsUttQ8rrz3SmIch9OnxUgKTTlT+1hSH3sU1sBo/ SXaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773341792; x=1773946592; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=K37CCclDFVHdKBYU3e8Fujk7zsuA6CY18RMwRlfjOaY=; b=hKty9iSj8IDyncLETTi84emR9VoLZSoPVL2tmMli3HoAPSHPDz3gYnFGx0tD9V+DM0 LR4SITj/borkwqh1cl9WFRKHghILix027NVNcN1weQ7S9E5IopenxzztSC+TNu2annkY IyXqYtbwDmyBKekKZf+PtfNAuJIiXdAkwA6Ey2XPRyZ7UFTC1mDI7tOsBGdTJyk6Beis 3MQTrvPCkgOd0REIcedGEtHCIebTngu4o9LmtL5rUt+vr2gdBzxKY9gVZ5obYLaEPVrQ Ds1xOIwgi0QU59F4OGOlS2OjUwPkf3KoJku3gyEvHLX6GGeHo5fj+fB0x6MyOqagmXsR IVgw== X-Forwarded-Encrypted: i=1; AJvYcCWhuejZ5AV6WvxxCgMb9DfMEbsplmyCqKLQ9JNQd0E0Up1/9uWDROnkOawhNk0GocIvftdKZvrB9JQUC7PR@postgresql.org X-Gm-Message-State: AOJu0YykH+UA1AoN4tg3v3OAUeE0J8jCuemmYrNaBOk2j7ouIGA0Qge/ NM7ROlGe6jP0w1cYRbFIy6EJnlCdIP6qc4eg74G4RsUXRre3Cexq7X2L1qQT/fYicgDMRftUgxb GvrvzpGbiSpU0oQeUfF3KrLNt4aYN8mM= X-Gm-Gg: ATEYQzw3T7k4yGZgP4IlkMWATzdc+3N0OwiFKZx6DzGKqqRaHk2qROM6v3jHHZ2Weja /8GuVI5+ZkCq9q4fj3aA1yG8hl4sBGDepqvHPy4m2316JTjMCNj04IGsm6g4shYA9W1uCStFnbW i/n6l0Vm6KZItAkJwo7uIoLxNAPEuqoFMhmx83xKaS9IHhXo3po+SfgEYW7VJE/C5PgIOnYuq6k NafaMKSy17nCKJ0saq8mkYrRkdmqLR2pBKsflcMyDVdqX87sNvS/WGMR0RVPGtF4A9rEoZhDe23 Ypiy+Kf2quduliRqqn1zjPUKLaBuHZmjdQ+xf7g= X-Received: by 2002:a17:907:934b:b0:b83:1433:78de with SMTP id a640c23a62f3a-b9764f4b53emr34612366b.12.1773341791945; Thu, 12 Mar 2026 11:56:31 -0700 (PDT) MIME-Version: 1.0 References: <5a37c2e3-619d-4816-84d7-0b27e3e6797f@iki.fi> <26c766d6-db0f-43d3-a618-44f8d40a3121@iki.fi> <62b8dc23-8f6a-4cac-91ff-f74bb5bc159a@iki.fi> In-Reply-To: <62b8dc23-8f6a-4cac-91ff-f74bb5bc159a@iki.fi> From: Robert Haas Date: Thu, 12 Mar 2026 14:56:18 -0400 X-Gm-Features: AaiRm53prrelSIsZpPDY9fJR_gLZAX3Md7EbbQ3xqkORGqfKM7ZuYu3h3g6c4K0 Message-ID: Subject: Re: Better shared data structure management and resizable shared data structures To: Heikki Linnakangas Cc: Ashutosh Bapat , Andres Freund , pgsql-hackers , chaturvedipalak1911@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Mar 12, 2026 at 2:41=E2=80=AFPM Heikki Linnakangas wrote: > shmem_startup_hook() is too late. The shmem structs need to be > registered at postmaster startup before the shmem segment is allocated, > so that we can calculate the total size needed. Sorry, I meant shmem_request_hook. > I'm currently leaning towards _PG_init(), except for allocations that > depend on MaxBackends. For those, you can install a shmem_request_hook > that sets the size in the descriptor. In other words, you can leave the > 'size' as empty in _PG_init(), but set it later in the shmem_request_hook= . Why can't you just do the whole thing later? > Another option is to add a new bespoken callback in the descriptor for > such size adjustments, which would get called at the same time as > shmem_request_hook. That might be a little more ergonomic, there would > no longer be any need for extensions to use the old > shmem_request/startup_hooks with the new ShmemRegisterStruct() mechanism. Yeah, worth considering. > Except that you'd still need them for RequestNamedLWLockTranche(). I > wonder if we should recommend extensions to embed the LWLock struct into > their shared memory struct and use the LWLockInitialize() and > LWLockNewTrancheId() functions instead. That fits the new > ShmemRegisterStruct() API a little better than RequestNamedLWLockTranche(= ). Yeah, I think RequestNamedLWLockTranche() might be fine if you just need LWLocks, but if you need a bunch of resources, putting them all into the same chunk of memory seems cleaner. --=20 Robert Haas EDB: http://www.enterprisedb.com