Re: Rename ShmemVariableCache and initialize it in more standard way

From: "Tristan Partin" <tristan(at)neon(dot)tech>
To: "Heikki Linnakangas" <hlinnaka(at)iki(dot)fi>, "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Cc: "Andres Freund" <andres(at)anarazel(dot)de>
Subject: Re: Rename ShmemVariableCache and initialize it in more standard way
Date: 2023-12-04 16:31:36
Message-ID: CXFOYNTXAF96.2U1ZER8HGNDEY@neon.tech
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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:
>
> On 11/07/2023 01:50, Andres Freund wrote:
> >> --- a/src/backend/storage/ipc/shmem.c
> >> +++ b/src/backend/storage/ipc/shmem.c
> >> @@ -144,6 +144,8 @@ InitShmemAllocation(void)
> >> /*
> >> * Initialize ShmemVariableCache for transaction manager. (This doesn't
> >> * really belong here, but not worth moving.)
> >> + *
> >> + * XXX: we really should move this
> >> */
> >> ShmemVariableCache = (VariableCache)
> >> ShmemAlloc(sizeof(*ShmemVariableCache));
> >
> > Heh. Indeed. And probably just rename it to something less insane.
>
> 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?

Patches look good to me.
--
Tristan Partin
Neon (https://neon.tech)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Drouvot, Bertrand 2023-12-04 16:36:56 Re: Synchronizing slots from primary to standby
Previous Message Ashutosh Bapat 2023-12-04 16:18:06 Re: Proposal: In-flight explain logging