Re: race condition when writing pg_control

From: amul sul <sulamul(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, "Bossart, Nathan" <bossartn(at)amazon(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: race condition when writing pg_control
Date: 2020-06-08 10:44:53
Message-ID: CAAJ_b96wp2R=pjg7XonXMBtiS_xk=Joe2WWXNm-O==JVVgHqGA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 29, 2020 at 12:54 PM Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
wrote:

>
>
> On 2020/05/27 16:10, Michael Paquier wrote:
> > On Tue, May 26, 2020 at 07:30:54PM +0000, Bossart, Nathan wrote:
> >> While an assertion in UpdateControlFile() would not have helped us
> >> catch the problem I initially reported, it does seem worthwhile to add
> >> it. I have attached a patch that adds this assertion and also
> >> attempts to fix XLogReportParameters(). Since there is only one place
> >> where we feel it is safe to call UpdateControlFile() without a lock, I
> >> just changed it to take the lock. I don't think this adds any sort of
> >> significant contention risk, and IMO it is a bit cleaner than the
> >> boolean flag.
> >
> > Let's see what Fujii-san and Thomas think about that. I'd rather
> > avoid taking a lock here because we don't need it and because it makes
> > things IMO confusing with the beginning of StartupXLOG() where a lot
> > of the fields are read, even if we go without this extra assertion.
>
> I have no strong opinion about this, but I tend to agree with Michael here.
>
>
I too don't have a strong opinion about this either, but I like Nathan's
approach more, just take the lock in the startup process as well for the
simplicity if that is not hurting much. I think, apart from the startup
process we
have to take the lock to update the control file, then having separate
treatment
for the startup process looks confusing to me, IMHO.

Regards,
Amul

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Euler Taveira 2020-06-08 10:51:18 Re: BUG #16481: Stored Procedure Triggered by Logical Replication is Unable to use Notification Events
Previous Message ahsan hadi 2020-06-08 10:24:58 Re: Improving psql slash usage help message