Re: Rename ShmemVariableCache and initialize it in more standard way - Mailing list pgsql-hackers

From Richard Guo
Subject Re: Rename ShmemVariableCache and initialize it in more standard way
Date
Msg-id CAMbWs49UvmEqtZm5B9Xw_9Y0j0CUq26j-kj+8_1KbpELM0ZTGg@mail.gmail.com
Whole thread Raw
In response to Re: Rename ShmemVariableCache and initialize it in more standard way  ("Tristan Partin" <tristan@neon.tech>)
Responses Re: Rename ShmemVariableCache and initialize it in more standard way
List 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

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Optimizing nbtree ScalarArrayOp execution, allowing multi-column ordered scans, skip scan
Next
From: Nathan Bossart
Date:
Subject: introduce dynamic shared memory registry