pgsql: Show size of DSAs and dshashes in pg_dsm_registry_allocations.

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Show size of DSAs and dshashes in pg_dsm_registry_allocations.
Date: 2025-12-02 16:31:25
Message-ID: E1vQTHh-002SV9-0d@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Show size of DSAs and dshashes in pg_dsm_registry_allocations.

Presently, this view reports NULL for the size of DSAs and dshash
tables because 1) the current backend might not be attached to them
and 2) the registry doesn't save the pointers to the dsa_area or
dshash_table in local memory. Also, the view doesn't show
partially-initialized entries to avoid ambiguity, since those
entries would report a NULL size as well.

This commit introduces a function that looks up the size of a DSA
given its handle (transiently attaching to the control segment if
needed) and teaches pg_dsm_registry_allocations to use it to show
the size of successfully-initialized DSA and dshash entries.
Furthermore, the view now reports partially-initialized entries
with a NULL size.

Reviewed-by: Rahila Syed <rahilasyed90(at)gmail(dot)com>
Reviewed-by: Robert Haas <robertmhaas(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://postgr.es/m/aSeEDeznAsHR1_YF%40nathan

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f894acb24a12cf1f369a45af36c8f4049f9af571

Modified Files
--------------
doc/src/sgml/system-views.sgml | 4 +--
src/backend/storage/ipc/dsm_registry.c | 25 ++++++----------
src/backend/utils/mmgr/dsa.c | 35 ++++++++++++++++++++++
src/include/utils/dsa.h | 1 +
.../expected/test_dsm_registry.out | 12 ++++----
.../test_dsm_registry/sql/test_dsm_registry.sql | 4 +--
6 files changed, 55 insertions(+), 26 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2025-12-02 19:27:03 pgsql: Add a test for half-dead pages in B-tree indexes
Previous Message Álvaro Herrera 2025-12-02 15:50:12 pgsql: Remove doc and code comments about ON CONFLICT deficiencies