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 1vQBZG-000zUk-1F for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Dec 2025 21:36:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQBZE-004Uj9-1G for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Dec 2025 21:36:20 +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 1vQBZD-004Uj1-30 for pgsql-hackers@lists.postgresql.org; Mon, 01 Dec 2025 21:36:20 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vQBZB-002cdg-0E for pgsql-hackers@lists.postgresql.org; Mon, 01 Dec 2025 21:36:18 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-29808a9a96aso53838125ad.1 for ; Mon, 01 Dec 2025 13:36:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764624974; x=1765229774; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=trkRy6shA/BL5RCxGBy1UwWNuGLg4Q65Se7EkNaHEE0=; b=M//AEOrSDTNGIx2l1IETVIzzRSBZjPqZTqTGapqnihZKA3tCUP+3uk+4axH4BHxwGE eFGJuadXtMCrtCZRs+Al3JCEPtXUCEQdgusDTJU4vdSeYW3yj4XwiiMsKDBrc2Hr+Sbo 52XCfO5JltCK5JQyIofiEjX6mKA7495TXkfxenwIkHwt0XO8biXZyUbfpa46KKYykkk2 UUetnjT7qz8Y+Z2fXudIBJBadfoj1cHPJvBVisErYN18yetiLxv8j/R6zLNLiDtfazq4 +03px3z1FTaStrn+SeW5+5qimyBYbeh3us3evJpzHvuX3tu+wuN2tiMd+5KAzmk3k3ST sZ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764624974; x=1765229774; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=trkRy6shA/BL5RCxGBy1UwWNuGLg4Q65Se7EkNaHEE0=; b=vJSFhJ1MJ5FeGJqWUwMTCSZjtzAlZ11vIqy/dCtq3d5shjnvrWFpH+aPKExS4RUG1L x99l+hR88y74OodTLuUPl1rd4cdBgLCUAPMmLddeVhLJPyR0vKAF4fHZh2RpIjvmNZF2 CjpewX3qD4Zs5hUAD1PVi813m8UFYoLenKt5K5luYGbpLM7tL/JEks/lswDZdN13ZHM/ UOX0+PEKxiQMTafFPG83PvI7I6OOAMBtJsFD04c4OaY5QdmZ8VdQne1wusekzSg3jAzk 4mVdFzCDvHZcfLkbGuQer5iBxyok0edadex5Dydiq34+yvXsg0/354z6nQX4/YMUrhMn O5fg== X-Forwarded-Encrypted: i=1; AJvYcCVTmOjd+K1tW10ix9UH6PyBUaqPQjMrXmWsqMIblk7ptwY7refIc5xGttaZ7UCKSzRRZCQXgsjQuvKHx5jy@lists.postgresql.org X-Gm-Message-State: AOJu0YyQrUqTrCsGKFzNTQ5esAs3zZBwSgg+JRjWl0Vbnhb+4DuLTeIw ZfXBE1Jp6BSKhacp+T33n9U7RzoNEE+r7BRD/TBRhi6wyUIeM6pP9CjT X-Gm-Gg: ASbGnctZaS9T/sWCHuTmwtcf/ZKYJNsSkK+lJlqfh9E+yfJgd7WOir1ZT1vfM9zP5nq R8U+gyIxdQIOCPT3rsUwJBxFurrjsXJSSsnFKTs1A9B21Z5cGBJIROymfCLC0h8FCk6ddvjh+uf ZocDtnC3VE+x4gnjYQdrbKAR/YByeqR7FNeCqLOY3lqTybw4+FnYf1HsPoyRwqGOP/S89YASyoI pnFhDvuKZ8AuzQGSc4c33HkDsG5QfQqRa5GS2Mso6mLgcqrFbqz2Pl3IrBI86F14eyqXkHEW8Px R84zpc8VKZ/jOlTptfNN+5aS0eqM1QFZ0Fk1GgPwrjIUwQcIlNfz6tM75HCvAOCTbjpvC+WUUaf TkykIDxfrbwVQA7CDaE8YQzchDcl8zAMSrNvG6L9J+YpQfrEo9cFKuDVCJeCHnRTcW/o4Iv4f04 dlhn1sPJNPrDI4l5O0y2o= X-Google-Smtp-Source: AGHT+IFiqaH2aFNM9nNDP3CVKTjKIWdis2adAEeJugB18sZijqDhLR1k/PQFN5+ItcJOqjLpS3KIaQ== X-Received: by 2002:a17:902:cec4:b0:298:5599:3ab0 with SMTP id d9443c01a7336-29b6beacbcfmr461430985ad.16.1764624974110; Mon, 01 Dec 2025 13:36:14 -0800 (PST) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29bceb27648sm133251735ad.52.2025.12.01.13.36.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Dec 2025 13:36:13 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: show size of DSAs and dshash tables in pg_dsm_registry_allocations From: Chao Li In-Reply-To: Date: Tue, 2 Dec 2025 05:35:34 +0800 Cc: Rahila Syed , Robert Haas , PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Nathan Bossart X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Nathan, V2 overall looks good to me. I just got a question and a few nit = comments. > On Dec 1, 2025, at 23:29, Nathan Bossart = wrote: >=20 > --=20 > nathan > 1 - dsa.c ``` +size_t +dsa_get_total_size_from_handle(dsa_handle handle) +{ + size_t size; + bool already_attached; + dsm_segment *segment; + dsa_area_control *control; + + already_attached =3D dsa_is_attached(handle); + if (already_attached) + segment =3D dsm_find_mapping(handle); + else + segment =3D dsm_attach(handle); + + if (segment =3D=3D NULL) + ereport(ERROR, + = (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), + errmsg("could not attach to dynamic = shared area"))); ``` Why do you error out instead of reporting 0/NULL usage here? When users = call this function as shown in the test script: ``` CREATE VIEW pg_dsm_registry_allocations AS SELECT * FROM pg_get_dsm_registry_allocations(); ``` User doesn=E2=80=99t pass in a handle, if the DSA has been released, it = should treat a missing mapping as =E2=80=9Cno size available=E2=80=9D = and maybe return NULL.=20 2 ``` + else if (entry->type =3D=3D DSMR_ENTRY_TYPE_DSH && + entry->dsh.dsa_handle = !=3DDSA_HANDLE_INVALID) ``` Missing a white space after !=3D. 3 ``` - Size of the allocation in bytes. NULL for entries of type - area and hash. + Size of the allocation in bytes. NULL for entries that failed + initialization. ``` =E2=80=9CFailed initialization=E2=80=9D, I guess =E2=80=9Cto=E2=80=9D is = needed after =E2=80=9Cfailed=E2=80=9D. 4 ``` -SELECT name, type, size IS DISTINCT FROM 0 AS size +SELECT name, type, size > 0 AS size ``` As you changed the third column from =E2=80=9Csize=E2=80=9D to =E2=80=9Csi= ze > 0=E2=80=9D, now it=E2=80=99s a bool column, so maybe rename the = column alias from =E2=80=9Csize=E2=80=9D to something indicating a bool = type, such as =E2=80=9Csize_ok=E2=80=9D, =E2=80=9Chas_size=E2=80=9D, = etc. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/