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

Nathan Bossart <nathandbossart@gmail.com>

From: Nathan Bossart <nathandbossart@gmail.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Nathan Bossart <nathan@postgresql.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-11-22T19:41:21Z
Lists: pgsql-hackers
On Sat, Nov 22, 2025 at 10:25:48AM -0500, Robert Haas wrote:
> On Thu, Nov 20, 2025 at 6:09 PM Nathan Bossart <nathandbossart@gmail.com> wrote:
>> Unpinning/detaching the segment/DSA/dshash table and deleting the DSM
>> registry entry in a PG_CATCH block scares me a little, but it might be
>> doable.
> 
> It seems a bit weird to be doing explicit unpinning in a PG_CATCH
> block. Ideally you'd want to postpone the pinning until initialization
> has succeeded, so that if you fail before that, transaction cleanup
> takes care of it automatically. Alternatively, destroying what existed
> before could be deferred until later, when an as-yet-unfailed
> transaction stumbles across the tombstone.

Oh, yeah, good idea.

> Am I worrying too much? Possibly! But as I said to David on another
> thread this morning, it's better to worry on pgsql-hackers before any
> problem happens than to start worrying after something bad happens in
> a customer situation.

I'll give what you suggested a try.  It seems reasonable enough.

-- 
nathan



Commits

  1. Teach DSM registry to retry entry initialization if needed.

  2. Revert "Teach DSM registry to ERROR if attaching to an uninitialized entry."

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