Re: Rename ShmemVariableCache and initialize it in more standard way

Richard Guo <guofenglinux@gmail.com>

From: Richard Guo <guofenglinux@gmail.com>
To: Tristan Partin <tristan@neon.tech>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>, pgsql-hackers <pgsql-hackers@postgresql.org>, Andres Freund <andres@anarazel.de>
Date: 2023-12-05T03:40:53Z
Lists: pgsql-hackers
On Tue, Dec 5, 2023 at 12:31 AM Tristan Partin <tristan@neon.tech> wrote:

> On Mon Dec 4, 2023 at 6:49 AM CST, Heikki Linnakangas wrote:
> > This came up in the "Refactoring backend fork+exec code" thread recently
> > [0], but is independent of that work:
> >
> > Here's a patch to allocate and initialize it with a pair of ShmemSize
> > and ShmemInit functions, like all other shared memory structs.
> >
> >  +        if (!IsUnderPostmaster)
> >  +        {
> >  +                Assert(!found);
> >  +                memset(ShmemVariableCache, 0,
> sizeof(VariableCacheData));
> >  +        }
> >  +        else
> >  +                Assert(found);
>
> Should the else branch instead be a fatal log?


The Assert here seems OK to me.  We do the same when initializing
commitTsShared/MultiXactState.  I think it would be preferable to adhere
to this convention.


> Patches look good to me.


Also +1 to the patches.

Thanks
Richard

Commits

  1. Rename ShmemVariableCache to TransamVariables

  2. Initialize ShmemVariableCache like other shmem areas