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 1w9xbB-001vYe-0x for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2026 03:59:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w9xb9-00EDXB-2R for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2026 03:59:32 +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 1w9xb9-00EDX2-1B for pgsql-hackers@lists.postgresql.org; Tue, 07 Apr 2026 03:59:31 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w9xb7-00000000xzC-3lY1 for pgsql-hackers@postgresql.org; Tue, 07 Apr 2026 03:59:30 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2b24fcc2b5dso30024505ad.1 for ; Mon, 06 Apr 2026 20:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775534369; cv=none; d=google.com; s=arc-20240605; b=PQwNzcAfKzm+Rlj8QROEc9btVDy6/OHC09NF9owLUcJ7kDw+gNcKgkywKwLY6l9M2b zcWvP0sjtpaxuW5oCpYi9CERt9QkgQZZB/kaAwHAnpQbaYj3SE3giap3yRIjswOV1EG5 2F6Qg/k2OX16ckimltuZWvS0oeKb0dNxnTK3rwkngdV+Hby7knpGGIjCQLl/jtK9s99+ 2aLJ+mutP5K1291lHepZcXXS2VqDIge/lCj+3CJ/R0IfVslp/a3fZnhbNUEXZSYOuEes QN/N4I0dCkxztDge9jvtgkceX9H30R1e8yg2M4x5pQwpBfu0evoGjWmMAJxsrXzmWAcA K+/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=XIgVYaqc2G3USetFKnKeQu0r+SumqOVPulXguQIoIo0=; fh=eVUSIqo8oW6GlS9+lJ2dMbh393DkmW/G0CKaTSrcg9Y=; b=jMcRqODVFZW5Ay8aRi8aWW3t6OxbjCyOoLlrYggK8NdNRIliEqyk08WcoJEGWNwC1q GCWneNsBiN1KzfZS2ePyW+ut2HHyEnc50dBjDVv31XAUd70DE0moAz7WL75Y7YW6tV4x P0SIxpB+KRB8HMdr3NXzD66ErCUV6spZ6Mk1zVqrys65e/UKLraUu2P5MDRi5R6ysQ9H DFmXdcSwA+P9PAJL0UTEqcRNrGiB2A2t+EYEegE01JUPI7v32aKUzDCF4d7w/Jv1XrA6 3ufkxiE7OPdESK4PtngSwdhfYMMec8QBHDVWJsm/URLIgVzXTcxbZeABE8Llgu1MCrLz bmLA==; 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=20251104; t=1775534369; x=1776139169; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=XIgVYaqc2G3USetFKnKeQu0r+SumqOVPulXguQIoIo0=; b=V80vZ0dDY51gvvNKXOyfqJk6jvT2SZo6U1Pmix9AeIlKyfs8JhrS4Ws7MpJA6rSAPT xuUp2S0hhr6nkq/b0fW7QRZvWGNLWfaQtWftJ+5y+cAmQcPqv3E+Zu+jPpRjzzacM02K 8+aZEQbpOg3HC267nB9cZe6QaCz6cwZtjAb3WdbUVq3X7c0a8my5s/GqJZPKZ0kdSZAH OJjLPQFt01hCQW3ymy/DFUvZkJSr6caRj+cYKHBLTpwDS4cONJ5K65lw+zNlOyrh+nCL mkS5kCHE/pKkJtj+4PwSSNbqOITUntmnFJj8wuRMbEFnShD7fBSSsM/ZgS8Ri2JEubTD FFVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775534369; x=1776139169; h=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=XIgVYaqc2G3USetFKnKeQu0r+SumqOVPulXguQIoIo0=; b=lM1EDuaoQ6bloKPZVVCxZ20Ua933FHv1lNBd5JaDEWdrUbnNO2HmON42U18dzwENdK eE8S8Bbh87j4dkfqm4kEO+MsVDHVu925X3Mm4MELf8gkL3J2TJj9xQaBItrElZ/v97/Y kBu1YkCbyZq6JjIHRPnoZrCgWbtmT7/aMXBj0+QuvYfELFn0c/OyVXdM+ofV9NMo+OqT fzuXkR1N6FttM+8g4upAJcDBuukDaJEko2IeP9c3ngondTEQ2at6vVkqqBAqNn57tjP6 wfqZXbP7Z4YZWXUqoPaYfFCR04d6HqSAMK436OGG+fYlGudm662Xr3VLShksZ8YzG9hO 1/DQ== X-Gm-Message-State: AOJu0Yw/ZKUY0/J03Qs7JVUm2PcrFymJVrxuoZcETbdbAqTwGGgAL4ml l/my8WRzDFEoxU7SAybVOoywwh/kFw5yxfgOqJot97Rg58uRXmwdfnLAAbIgNBPxIVlAqMOrefN gTzAb6FJCJVUxGg916HBK6xi7iL8OuZUe5T2mrkvuXu1L X-Gm-Gg: AeBDieumhP8LJimOvTPRDsIPKIDFK7Ow6fT+N/+2/DZzNTZo+srgEEvpM3UjVJ+gxMi QEyC7sd0cYO0GAIvWLHg7/wajifj0xpvLfwd+uk3UtQed37U0WIHME4JWe56Z0h1ETQR4X3BIVl SXbZcW0e3JO5ZvtCP0k4SJrKab9jWGoLkwvjxA7tQLfznoL9Jn/4UUtFSMAZ4ZqOo99CQoRAVIx nTPI+VKVHQRINexCliz3fcesulZa3HO/wisHz3SqH3c5lz2gG7eK5H/xlu8xTrkMRq/vTlrMPzu hFINYdg9Y1BNcUMfUsDD1NeJyY7fK+/ia4TGlLLNIYs= X-Received: by 2002:a17:902:f611:b0:2b0:5cb4:d894 with SMTP id d9443c01a7336-2b28173fe0amr166336595ad.13.1775534369169; Mon, 06 Apr 2026 20:59:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: jie wang Date: Tue, 7 Apr 2026 11:59:14 +0800 X-Gm-Features: AQROBzB337kafG_BjFH2lr-UUTd__wP_x3l4FsVoOdf3irUu_0YVn6skDTbkDC8 Message-ID: Subject: Re: Return DSA area for hash table from GetNamedDSHash() To: Sami Imseih Cc: pgsql-hackers Content-Type: multipart/alternative; boundary="0000000000005c6337064ed6cf8e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000005c6337064ed6cf8e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sami Imseih =E4=BA=8E2026=E5=B9=B44=E6=9C=887=E6=97= =A5=E5=91=A8=E4=BA=8C 06:56=E5=86=99=E9=81=93=EF=BC=9A > Hi, > > While working on extending tests for dshash.c [1], I realized that a > user that creates a hash table with GetNamedDSHash() has no way > to cap the size of the dsa area underpinning the table by using > dsa_set_size_limit(). This is because the dsa_area created using > this API is not exposed to the user. > > This is a gap for users of the GetNamedDSHash() API, > because it's very likely that the callers don't want runaway growth of > these hash tables. > > Attached is a new API, dshash_get_dsa_area() that takes in a dshash_table > and returns the area. The caller can then use dsa_set_size_limit() to lim= it > the size. > > We could change the GetNamedDSHash() API to take in a size, but that > will not be ideal since a caller may want to change the size dynamically > after > the hash table is created. > > I don't have a patch for this yet, but I also think it will make sense fo= r > pg_dsm_registry_allocations to also show the max_size > > postgres=3D# select * from pg_dsm_registry_allocations; > name | type | size > ------------------------+---------+--------- > test_dsm_registry_dsa | area | 1048576 > test_dsm_registry_hash | hash | 1048576 > test_dsm_registry_dsm | segment | 20 > (3 rows) > > Thoughts? > > > [1] [https://www.postgresql.org/message-id/acXCJODjsCytdpwT%40paquier.xyz= ] > > -- > Sami Imseih > Amazon Web Services (AWS) > Hi, I think an assert check could be added in this patch for better safety. Assert(hash_table !=3D NULL); Best regards, -- wang jie --0000000000005c6337064ed6cf8e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Sami Imseih <= ;samimseih@gmail.com> =E4=BA= =8E2026=E5=B9=B44=E6=9C=887=E6=97=A5=E5=91=A8=E4=BA=8C 06:56=E5=86=99=E9=81= =93=EF=BC=9A
Hi,=

While working on extending tests for dshash.c [1], I realized that a
user that creates a hash table with GetNamedDSHash() has no way
to cap the size of the dsa area underpinning the table by using
dsa_set_size_limit(). This is because the dsa_area created using
this API is not exposed to the user.

This is a gap for users of the GetNamedDSHash() API,
because it's very likely that the callers don't want runaway growth= of
these hash tables.

Attached is a new API, dshash_get_dsa_area() that takes in a dshash_table and returns the area. The caller can then use dsa_set_size_limit() to limit=
the size.

We could change the GetNamedDSHash() API to take in a size, but that
will not be ideal since a caller may want to change the size dynamically af= ter
the hash table is created.

I don't have a patch for this yet, but I also think it will make sense = for
pg_dsm_registry_allocations to also show the max_size

postgres=3D# select * from pg_dsm_registry_allocations;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 name=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |= =C2=A0 type=C2=A0 =C2=A0|=C2=A0 size
------------------------+---------+---------
=C2=A0test_dsm_registry_dsa=C2=A0 | area=C2=A0 =C2=A0 | 1048576
=C2=A0test_dsm_registry_hash | hash=C2=A0 =C2=A0 | 1048576
=C2=A0test_dsm_registry_dsm=C2=A0 | segment |=C2=A0 =C2=A0 =C2=A0 20
(3 rows)

Thoughts?


[1] [https://www.postgresql.org/= message-id/acXCJODjsCytdpwT%40paquier.xyz]

--
Sami Imseih
Amazon Web Services (AWS)


Hi,=

I think an assert check could be added in this patch for better saf= ety.
=C2=A0Assert(hash_table !=3D NULL);

Best regards,
--
<= div>wang jie=C2=A0
--0000000000005c6337064ed6cf8e--