Re: Lock on ShmemVariableCache fields? - Mailing list pgsql-hackers

From Japin Li
Subject Re: Lock on ShmemVariableCache fields?
Date
Msg-id MEYP282MB16695B0701EA4D7A4471A74AB6379@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Whole thread Raw
In response to Re: Lock on ShmemVariableCache fields?  (Zhang Mingli <zmlpostgres@gmail.com>)
Responses Re: Lock on ShmemVariableCache fields?  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
On Mon, 31 Oct 2022 at 14:15, Zhang Mingli <zmlpostgres@gmail.com> wrote:
> HI,
>
> On Oct 31, 2022, 10:48 +0800, Japin Li <japinli@hotmail.com>, wrote:
>>
>> I also find a similar code in StartupXLOG(). Why we don't hold the lock
>> on OidGenLock when updating ShmemVariableCache->nextOid and
>> ShmemVariableCache->oidCount?
>>
>> If the lock is unnecessary, I think adding some comments is better.
>>
> As its name BootStrapXLOG, it’s used in BootStrap mode to initialize the template database.
> The process doesn’t speak SQL and the database is not ready.
> There won’t be  concurrent access to variables.
>

Thanks for your explanation.  I got your mind.  So, in theory, we can also update
everything in ShmemVariableCache without a lock?

For example, since SetCommitTsLimit() is only used in BootStrapXLog() and
StartupXLOG(), we can safely remove the code of acquiring/releasing lock?

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Adding doubly linked list type which stores the number of items in the list
Next
From: Peter Smith
Date:
Subject: Re: Support logical replication of DDLs