Re: Is it correct to update db state in control file as "shutting down" during end-of-recovery checkpoint? - Mailing list pgsql-hackers

From Bharath Rupireddy
Subject Re: Is it correct to update db state in control file as "shutting down" during end-of-recovery checkpoint?
Date
Msg-id CALj2ACVn5M8xgQ3RD=6rSTbbXRBdBWZ=TTOBOY_5+edMCkWjHA@mail.gmail.com
Whole thread Raw
In response to Re: Is it correct to update db state in control file as "shutting down" during end-of-recovery checkpoint?  ("Bossart, Nathan" <bossartn@amazon.com>)
Responses Re: Is it correct to update db state in control file as "shutting down" during end-of-recovery checkpoint?
List pgsql-hackers
On Tue, Dec 7, 2021 at 12:58 AM Bossart, Nathan <bossartn@amazon.com> wrote:
>
> On 12/6/21, 4:34 AM, "Bharath Rupireddy" <bharath.rupireddyforpostgres@gmail.com> wrote:
> > While the database is performing end-of-recovery checkpoint, the
> > control file gets updated with db state as "shutting down" in
> > CreateCheckPoint (see the code snippet at [1]) and at the end it sets
> > it back to "shut down" for a brief moment and then finally to "in
> > production". If the end-of-recovery checkpoint takes a lot of time or
> > the db goes down during the end-of-recovery checkpoint for whatever
> > reasons, the control file ends up having the wrong db state.
> >
> > Should we add a new db state something like
> > DB_IN_END_OF_RECOVERY_CHECKPOINT/"in end-of-recovery checkpoint" or
> > something else to represent the correct state?
>
> This seems like a reasonable change to me.  From a quick glance, it
> looks like it should be a simple fix that wouldn't add too much
> divergence between the shutdown and end-of-recovery checkpoint code
> paths.

Here's a patch that I've come up with. Please see if this looks okay
and let me know if we want to take it forward so that I can add a CF
entry.

The new status one would see is as follows:
bharath@bharathubuntu3:~/postgres/inst/bin$ ./pg_controldata -D data
pg_control version number:            1500
Catalog version number:               202111301
Database system identifier:           7038867865889221935
Database cluster state:               in end-of-recovery checkpoint
pg_control last modified:             Tue Dec  7 08:06:18 2021
Latest checkpoint location:           0/14D24A0
Latest checkpoint's REDO location:    0/14D24A0
Latest checkpoint's REDO WAL file:    000000010000000000000001

Regards,
Bharath Rupireddy.

Attachment

pgsql-hackers by date:

Previous
From: Hans Buschmann
Date:
Subject: AW: Assorted improvements in pg_dump
Next
From: Bharath Rupireddy
Date:
Subject: Re: Do we need pre-allocate WAL files during end-of-recovery checkpoint?