From 87597fd8bac041897626a9806000b042ccc7b68a Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Wed, 8 Dec 2021 09:09:56 +0000 Subject: [PATCH v1] Skip control file db state updation during end-of-recovery checkpoint While the database is performing end-of-recovery checkpoint, the control file gets updated with db state as "shutting down" in CreateCheckPoint and at the end it sets it back to "shut down" for a brief moment and then finally to "in production". Intead, let the db state be in DB_IN_CRASH_RECOVERY which then changes to DB_IN_PRODUCTION. --- src/backend/access/transam/xlog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index d894af310a..3f83b5e3f2 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -9137,7 +9137,7 @@ CreateCheckPoint(int flags) */ START_CRIT_SECTION(); - if (shutdown) + if (flags & CHECKPOINT_IS_SHUTDOWN) { LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); ControlFile->state = DB_SHUTDOWNING; @@ -9406,7 +9406,7 @@ CreateCheckPoint(int flags) * Update the control file. */ LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); - if (shutdown) + if (flags & CHECKPOINT_IS_SHUTDOWN) ControlFile->state = DB_SHUTDOWNED; ControlFile->checkPoint = ProcLastRecPtr; ControlFile->checkPointCopy = checkPoint; -- 2.25.1