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 Is it correct to update db state in control file as "shutting down" during end-of-recovery checkpoint?
Date
Msg-id CALj2ACVvy+06hv7HocOFAHEBZWxLbc-t_61axdCUq9NaR2-c0Q@mail.gmail.com
Whole thread Raw
Responses Re: Is it correct to update db state in control file as "shutting down" during end-of-recovery checkpoint?  ("Bossart, Nathan" <bossartn@amazon.com>)
List pgsql-hackers
Hi,

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?

Thoughts?

[1]
void
CreateCheckPoint(int flags)
{

    /*
     * An end-of-recovery checkpoint is really a shutdown checkpoint, just
     * issued at a different time.
     */
    if (flags & (CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_END_OF_RECOVERY))
        shutdown = true;
    else
        shutdown = false;

    if (shutdown)
    {
        LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);
        ControlFile->state = DB_SHUTDOWNING;
        UpdateControlFile();
        LWLockRelease(ControlFileLock);
    }

    if (shutdown)
        ControlFile->state = DB_SHUTDOWNED;

Regards,
Bharath Rupireddy.



pgsql-hackers by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Re: Shouldn't postgres_fdw report warning when it gives up getting result from foreign server?
Next
From: "Euler Taveira"
Date:
Subject: Re: row filtering for logical replication