Show size of DSAs and dshashes in pg_dsm_registry_allocations.
authorNathan Bossart <[email protected]>
Tue, 2 Dec 2025 16:29:45 +0000 (10:29 -0600)
committerNathan Bossart <[email protected]>
Tue, 2 Dec 2025 16:29:45 +0000 (10:29 -0600)
commitf894acb24a12cf1f369a45af36c8f4049f9af571
tree74809e7b4b473e59fc68b6ced4a4157d658c37bd
parent758479213d574d6e2fbbdfee5328edef3d60da61
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 <[email protected]>
Reviewed-by: Robert Haas <[email protected]>
Reviewed-by: Chao Li <[email protected]>
Discussion: https://postgr.es/m/aSeEDeznAsHR1_YF%40nathan
doc/src/sgml/system-views.sgml
src/backend/storage/ipc/dsm_registry.c
src/backend/utils/mmgr/dsa.c
src/include/utils/dsa.h
src/test/modules/test_dsm_registry/expected/test_dsm_registry.out
src/test/modules/test_dsm_registry/sql/test_dsm_registry.sql