Re: Lock on ShmemVariableCache fields?

From: Japin Li <japinli(at)hotmail(dot)com>
To: Zhang Mingli <zmlpostgres(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Lock on ShmemVariableCache fields?
Date: 2022-10-31 07:14:54
Message-ID: MEYP282MB16695B0701EA4D7A4471A74AB6379@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Mon, 31 Oct 2022 at 14:15, Zhang Mingli <zmlpostgres(at)gmail(dot)com> wrote:
> HI,
>
> On Oct 31, 2022, 10:48 +0800, Japin Li <japinli(at)hotmail(dot)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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2022-10-31 08:07:37 Re: Support logical replication of DDLs
Previous Message David Rowley 2022-10-31 07:14:16 Re: Adding doubly linked list type which stores the number of items in the list