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

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: "Bossart, Nathan" <bossartn(at)amazon(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Is it correct to update db state in control file as "shutting down" during end-of-recovery checkpoint?
Date: 2021-12-07 08:09:13
Message-ID: CALj2ACVn5M8xgQ3RD=6rSTbbXRBdBWZ=TTOBOY_5+edMCkWjHA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 7, 2021 at 12:58 AM Bossart, Nathan <bossartn(at)amazon(dot)com> wrote:
>
> On 12/6/21, 4:34 AM, "Bharath Rupireddy" <bharath(dot)rupireddyforpostgres(at)gmail(dot)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(at)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 Content-Type Size
v1-0001-Add-DB_IN_END_OF_RECOVERY_CHECKPOINT-state-for-co.patch application/x-patch 3.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2021-12-07 08:20:42 Re: Do we need pre-allocate WAL files during end-of-recovery checkpoint?
Previous Message Hans Buschmann 2021-12-07 08:05:32 AW: Assorted improvements in pg_dump