Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d561430

Browse files
committed
On clean shutdown during recovery, don't warn about possible corruption.
Fujii Masao. Review by Heikki Linnakangas and myself.
1 parent f0c437c commit d561430

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/backend/access/transam/xlog.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.415 2010/06/02 09:28:44 heikki Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.416 2010/06/03 03:19:59 rhaas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -5661,6 +5661,10 @@ StartupXLOG(void)
56615661
ereport(LOG,
56625662
(errmsg("database system was shut down at %s",
56635663
str_time(ControlFile->time))));
5664+
else if (ControlFile->state == DB_SHUTDOWNED_IN_RECOVERY)
5665+
ereport(LOG,
5666+
(errmsg("database system was shut down in recovery at %s",
5667+
str_time(ControlFile->time))));
56645668
else if (ControlFile->state == DB_SHUTDOWNING)
56655669
ereport(LOG,
56665670
(errmsg("database system shutdown was interrupted; last known up at %s",
@@ -7548,6 +7552,14 @@ CreateRestartPoint(int flags)
75487552
lastCheckPoint.redo.xlogid, lastCheckPoint.redo.xrecoff)));
75497553

75507554
UpdateMinRecoveryPoint(InvalidXLogRecPtr, true);
7555+
if (flags & CHECKPOINT_IS_SHUTDOWN)
7556+
{
7557+
LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);
7558+
ControlFile->state = DB_SHUTDOWNED_IN_RECOVERY;
7559+
ControlFile->time = (pg_time_t) time(NULL);
7560+
UpdateControlFile();
7561+
LWLockRelease(ControlFileLock);
7562+
}
75517563
LWLockRelease(CheckpointLock);
75527564
return false;
75537565
}
@@ -7585,6 +7597,8 @@ CreateRestartPoint(int flags)
75857597
ControlFile->checkPoint = lastCheckPointRecPtr;
75867598
ControlFile->checkPointCopy = lastCheckPoint;
75877599
ControlFile->time = (pg_time_t) time(NULL);
7600+
if (flags & CHECKPOINT_IS_SHUTDOWN)
7601+
ControlFile->state = DB_SHUTDOWNED_IN_RECOVERY;
75887602
UpdateControlFile();
75897603
}
75907604
LWLockRelease(ControlFileLock);

src/bin/pg_controldata/pg_controldata.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
77
* licence: BSD
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.49 2010/04/28 19:38:49 tgl Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.50 2010/06/03 03:20:00 rhaas Exp $
1010
*/
1111

1212
/*
@@ -57,6 +57,8 @@ dbState(DBState state)
5757
return _("starting up");
5858
case DB_SHUTDOWNED:
5959
return _("shut down");
60+
case DB_SHUTDOWNED_IN_RECOVERY:
61+
return _("shut down in recovery");
6062
case DB_SHUTDOWNING:
6163
return _("shutting down");
6264
case DB_IN_CRASH_RECOVERY:

src/include/catalog/pg_control.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.54 2010/04/28 16:10:43 heikki Exp $
11+
* $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.55 2010/06/03 03:20:00 rhaas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -65,6 +65,7 @@ typedef enum DBState
6565
{
6666
DB_STARTUP = 0,
6767
DB_SHUTDOWNED,
68+
DB_SHUTDOWNED_IN_RECOVERY,
6869
DB_SHUTDOWNING,
6970
DB_IN_CRASH_RECOVERY,
7071
DB_IN_ARCHIVE_RECOVERY,

0 commit comments

Comments
 (0)