Re: Deduplicate code updating ControleFile's DBState. - Mailing list pgsql-hackers

From Bossart, Nathan
Subject Re: Deduplicate code updating ControleFile's DBState.
Date
Msg-id 4ABB6AFC-7416-4A52-8C67-729AA586050B@amazon.com
Whole thread Raw
In response to Deduplicate code updating ControleFile's DBState.  (Amul Sul <sulamul@gmail.com>)
Responses Re: Deduplicate code updating ControleFile's DBState.
List pgsql-hackers
On 9/13/21, 11:06 PM, "Amul Sul" <sulamul@gmail.com> wrote:
> The patch is straightforward but the only concern is that in
> StartupXLOG(), SharedRecoveryState now gets updated only with spin
> lock; earlier it also had ControlFileLock in addition to that. AFAICU,
> I don't see any problem there, since until the startup process exists
> other backends could not connect and write a WAL record.

It looks like ebdf5bf intentionally made sure that we hold
ControlFileLock while updating SharedRecoveryInProgress (now
SharedRecoveryState after 4e87c48).  The thread for this change [0]
has some additional details.

As far as the patch goes, I'm not sure why SetControlFileDBState()
needs to be exported, and TBH I don't know if this change is really a
worthwhile improvement.  ISTM the main benefit is that it could help
avoid cases where we update the state but not the time.  However,
there's still nothing preventing that, and I don't get the idea that
it was really a big problem to begin with.

Nathan

[0] https://postgr.es/m/CAB7nPqTS5J3-G_zTow0Kc5oqZn877RDDN1Mfcqm2PscAS7FnAw%40mail.gmail.com


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: SQL/JSON: JSON_TABLE - pg_stat_statements crash
Next
From: Alexander Lakhin
Date:
Subject: Re: Don't clean up LLVM state when exiting in a bad way