pgsql: Teach DSM registry to ERROR if attaching to an uninitialized ent

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Teach DSM registry to ERROR if attaching to an uninitialized ent
Date: 2025-11-12 20:31:10
Message-ID: E1vJHUk-006I7r-37@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Teach DSM registry to ERROR if attaching to an uninitialized entry.

If DSM entry initialization fails, backends could try to use an
uninitialized DSM segment, DSA, or dshash table (since the entry is
still added to the registry). To fix, keep track of whether
initialization completed, and ERROR if a backend tries to attach to
an uninitialized entry. We could instead retry initialization as
needed, but that seemed complicated, error prone, and unlikely to
help most cases. Furthermore, such problems probably indicate a
coding error.

Reported-by: Alexander Lakhin <exclusion(at)gmail(dot)com>
Reviewed-by: Sami Imseih <samimseih(at)gmail(dot)com>
Discussion: https://postgr.es/m/dd36d384-55df-4fc2-825c-5bc56c950fa9%40gmail.com
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1165a933aab1355757a43cfd9193b6cce06f573b

Modified Files
--------------
src/backend/storage/ipc/dsm_registry.c | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Nathan Bossart 2025-11-12 20:31:11 pgsql: Teach DSM registry to ERROR if attaching to an uninitialized ent
Previous Message Heikki Linnakangas 2025-11-12 19:34:09 pgsql: Clear 'xid' in dummy async notify entries written to fill up pag

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Jacobson 2025-11-12 20:37:51 Re: Optimize LISTEN/NOTIFY
Previous Message Nathan Bossart 2025-11-12 20:10:16 Re: another autovacuum scheduling thread