Re: Deduplicate code updating ControleFile's DBState.

From: Amul Sul <sulamul(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: "Bossart, Nathan" <bossartn(at)amazon(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Deduplicate code updating ControleFile's DBState.
Date: 2021-09-20 04:34:53
Message-ID: CAAJ_b94bQa_PZeaKd+0NnBxhq=omPzw2+HYrX1MQD-SKB6w0zg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 16, 2021 at 5:17 AM Michael Paquier <michael(at)paquier(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Antonin Houska 2021-09-20 04:56:14 Re: POC: Cleaning up orphaned files using undo logs
Previous Message Kevin Burke 2021-09-20 03:37:18 Coding guidelines for braces + spaces - link 404's