]> granicus.if.org Git - postgresql/commitdiff
On clean shutdown during recovery, don't warn about possible corruption.
authorRobert Haas <rhaas@postgresql.org>
Thu, 3 Jun 2010 03:20:00 +0000 (03:20 +0000)
committerRobert Haas <rhaas@postgresql.org>
Thu, 3 Jun 2010 03:20:00 +0000 (03:20 +0000)
Fujii Masao.  Review by Heikki Linnakangas and myself.

src/backend/access/transam/xlog.c
src/bin/pg_controldata/pg_controldata.c
src/include/catalog/pg_control.h

index 0a14c522e983b0440e81aa6012f9029292a9e5f8..c154dae0a7561692e5c84cbd91e77833e0ebc1df 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.415 2010/06/02 09:28:44 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.416 2010/06/03 03:19:59 rhaas Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -5661,6 +5661,10 @@ StartupXLOG(void)
                ereport(LOG,
                                (errmsg("database system was shut down at %s",
                                                str_time(ControlFile->time))));
+       else if (ControlFile->state == DB_SHUTDOWNED_IN_RECOVERY)
+               ereport(LOG,
+                               (errmsg("database system was shut down in recovery at %s",
+                                               str_time(ControlFile->time))));
        else if (ControlFile->state == DB_SHUTDOWNING)
                ereport(LOG,
                                (errmsg("database system shutdown was interrupted; last known up at %s",
@@ -7548,6 +7552,14 @@ CreateRestartPoint(int flags)
                                  lastCheckPoint.redo.xlogid, lastCheckPoint.redo.xrecoff)));
 
                UpdateMinRecoveryPoint(InvalidXLogRecPtr, true);
+               if (flags & CHECKPOINT_IS_SHUTDOWN)
+               {
+                       LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);
+                       ControlFile->state = DB_SHUTDOWNED_IN_RECOVERY;
+                       ControlFile->time = (pg_time_t) time(NULL);
+                       UpdateControlFile();
+                       LWLockRelease(ControlFileLock);
+               }
                LWLockRelease(CheckpointLock);
                return false;
        }
@@ -7585,6 +7597,8 @@ CreateRestartPoint(int flags)
                ControlFile->checkPoint = lastCheckPointRecPtr;
                ControlFile->checkPointCopy = lastCheckPoint;
                ControlFile->time = (pg_time_t) time(NULL);
+               if (flags & CHECKPOINT_IS_SHUTDOWN)
+                       ControlFile->state = DB_SHUTDOWNED_IN_RECOVERY;
                UpdateControlFile();
        }
        LWLockRelease(ControlFileLock);
index 5b156a36def82950f52e93250600c7138c826ba4..b62b59e0dc83f3eed97e94a795ec44894558a003 100644 (file)
@@ -6,7 +6,7 @@
  * copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
  * licence: BSD
  *
- * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.49 2010/04/28 19:38:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.50 2010/06/03 03:20:00 rhaas Exp $
  */
 
 /*
@@ -57,6 +57,8 @@ dbState(DBState state)
                        return _("starting up");
                case DB_SHUTDOWNED:
                        return _("shut down");
+               case DB_SHUTDOWNED_IN_RECOVERY:
+                       return _("shut down in recovery");
                case DB_SHUTDOWNING:
                        return _("shutting down");
                case DB_IN_CRASH_RECOVERY:
index 8deef6d354d55ad80566bbdbba88baf39fbb248d..e61f213a6248d35dffd7c7a2ca0b8ce263da84e0 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.54 2010/04/28 16:10:43 heikki Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.55 2010/06/03 03:20:00 rhaas Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -65,6 +65,7 @@ typedef enum DBState
 {
        DB_STARTUP = 0,
        DB_SHUTDOWNED,
+       DB_SHUTDOWNED_IN_RECOVERY,
        DB_SHUTDOWNING,
        DB_IN_CRASH_RECOVERY,
        DB_IN_ARCHIVE_RECOVERY,