Re: race condition when writing pg_control - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: race condition when writing pg_control
Date
Msg-id 20200523053935.GB266978@paquier.xyz
Whole thread Raw
In response to Re: race condition when writing pg_control  (Fujii Masao <masao.fujii@oss.nttdata.com>)
Responses Re: race condition when writing pg_control  ("Bossart, Nathan" <bossartn@amazon.com>)
List pgsql-hackers
On Sat, May 23, 2020 at 01:00:17AM +0900, Fujii Masao wrote:
> Per my quick check, XLogReportParameters() seems to have the similar issue,
> i.e., it updates the control file without taking ControlFileLock.
> Maybe we should fix this at the same time?

Yeah.  It also checks the control file values, implying that we should
have LW_SHARED taken at least at the beginning, but this lock cannot
be upgraded we need LW_EXCLUSIVE the whole time.  I am wondering if we
should check with an assert if ControlFileLock is taken when going
through UpdateControlFile().  We have one code path at the beginning
of redo where we don't need a lock close to the backup_label file
checks, but we could just pass down a boolean flag to the routine to
handle that case.  Another good thing in having an assert is that any
new caller of UpdateControlFile() would need to think about the need
of a lock.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Adding missing object access hook invocations
Next
From: Julien Rouhaud
Date:
Subject: Re: Planning counters in pg_stat_statements (using pgss_store)