On Thu, Sep 16, 2021 at 5:17 AM Michael Paquier <mich...@paquier.xyz> wrote:
>
> On Wed, Sep 15, 2021 at 10:49:39PM +0000, Bossart, Nathan wrote:
> > Ah, I was missing this context.  Perhaps this should be included in
> > the patch set for the other thread, especially if it will need to be
> > exported.
>
> This part of the patch is mentioned at the top of the thread:
> -   LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);
> -   ControlFile->state = DB_IN_PRODUCTION;
> -   ControlFile->time = (pg_time_t) time(NULL);
> -
> +   SetControlFileDBState(DB_IN_PRODUCTION);
>     SpinLockAcquire(&XLogCtl->info_lck);
>     XLogCtl->SharedRecoveryState = RECOVERY_STATE_DONE;
>     SpinLockRelease(&XLogCtl->info_lck);
>
> There is an assumption in this code to update SharedRecoveryState
> *while* holding ControlFileLock.  For example, see the following
> comment in xlog.c, ReadRecord():
> /*
>  * We update SharedRecoveryState while holding the lock on
>  * ControlFileLock so both states are consistent in shared
>  * memory.
>  */

Ok, understood, let's do that update with ControlFileLock, thanks.

Regards,
Amul


Reply via email to