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

From Michael Paquier
Subject Re: Deduplicate code updating ControleFile's DBState.
Date
Msg-id YaCC2vow5U8QcVrh@paquier.xyz
Whole thread Raw
In response to Re: Deduplicate code updating ControleFile's DBState.  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Deduplicate code updating ControleFile's DBState.
List pgsql-hackers
On Thu, Nov 25, 2021 at 04:04:23PM +0900, Michael Paquier wrote:
> I have not check the performance implication of that with a micro
> benchmark or the like, but I can get behind 0001 on consistency
> grounds between the backend and the frontend.

    /* Now create pg_control */
    InitControlFile(sysidentifier);
-   ControlFile->time = checkPoint.time;
    ControlFile->checkPoint = checkPoint.redo;
    ControlFile->checkPointCopy = checkPoint;
0001 has a mistake here, no?  The initial control file creation goes
through WriteControlFile(), and not update_controlfile(), so this
change means that we would miss setting up this timestamp for the
first time.

@@ -714,7 +714,6 @@ GuessControlValues(void)
    ControlFile.checkPointCopy.oldestActiveXid = InvalidTransactionId;

    ControlFile.state = DB_SHUTDOWNED;
-   ControlFile.time = (pg_time_t) time(NULL);
This one had better not be removed, either, as we require pg_resetwal
to guess a set of control file values.  Removing the one in
RewriteControlFile() is fine, on the contrary.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: row filtering for logical replication
Next
From: Michael Paquier
Date:
Subject: Re: pg_dump, pg_basebackup don't error out with wrong option for "--format"