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

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Nathan Bossart <nathan(at)postgresql(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgsql: Teach DSM registry to ERROR if attaching to an uninitialized ent
Date: 2025-11-20 15:44:31
Message-ID: CA+TgmoZGFzLJpYANBG9yDyoakVm-P2Acdker-Y+DHvPWfvBE5w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Wed, Nov 12, 2025 at 3:31 PM Nathan Bossart <nathan(at)postgresql(dot)org> wrote:
> 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.

Having read the thread that led to this commit, I agree that this is
an improvement, but it still doesn't seem like a great situation to
me. Maybe I'm misunderstanding, but it seems like once the
initialization has failed, there's no way to retry: you can't retry
the initialization on the existing segment, and you can't delete it
and create a new segment. If so, that means your only option for
restoring proper function after an initialization failure is to bounce
the entire server.

Now, perhaps the chances of an initialization failure in practice are
quite low. Maybe a typical initialization function won't do anything
that could fail. But it just seems weird to me to design something
that thinks errors are likely enough that it's worth having some
amount of mechanism to deal with them, but unlikely enough that it's
not worth making that mechanism more robust.

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Melanie Plageman 2025-11-20 16:04:59 pgsql: Keep all_frozen updated in heap_page_prune_and_freeze
Previous Message Melanie Plageman 2025-11-20 15:35:07 pgsql: Refactor heap_page_prune_and_freeze() parameters into a struct

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2025-11-20 16:12:47 Re: pgsql: Teach DSM registry to ERROR if attaching to an uninitialized ent
Previous Message Álvaro Herrera 2025-11-20 15:43:58 Re: Remove useless casts to (void *)