mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-13 18:07:05 +08:00
Write an end-of-backup WAL record at pg_stop_backup(), and wait for it at
recovery instead of reading the backup history file. This is more robust, as it stops you from prematurely starting up an inconsisten cluster if the backup history file is lost for some reason, or if the base backup was never finished with pg_stop_backup(). This also paves the way for a simpler streaming replication patch, which doesn't need to care about backup history files anymore. The backup history file is still created and archived as before, but it's not used by the system anymore. It's just for informational purposes now. Bump PG_CONTROL_VERSION as the location of the backup startpoint is now written to a new field in pg_control, and catversion because initdb is required Original patch by Fujii Masao per Simon's idea, with further fixes by me.
This commit is contained in:
@ -37,7 +37,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/catversion.h,v 1.565 2010/01/02 16:58:01 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.566 2010/01/04 12:50:49 heikki Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -53,6 +53,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 201001011
|
||||
#define CATALOG_VERSION_NO 201001041
|
||||
|
||||
#endif
|
||||
|
||||
@ -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.47 2010/01/02 16:58:01 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.48 2010/01/04 12:50:50 heikki Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
|
||||
/* Version identifier for this pg_control format */
|
||||
#define PG_CONTROL_VERSION 852
|
||||
#define PG_CONTROL_VERSION 853
|
||||
|
||||
/*
|
||||
* Body of CheckPoint XLOG records. This is declared here because we keep
|
||||
@ -62,6 +62,7 @@ typedef struct CheckPoint
|
||||
#define XLOG_NOOP 0x20
|
||||
#define XLOG_NEXTOID 0x30
|
||||
#define XLOG_SWITCH 0x40
|
||||
#define XLOG_BACKUP_END 0x50
|
||||
|
||||
|
||||
/* System status indicator */
|
||||
@ -117,7 +118,27 @@ typedef struct ControlFileData
|
||||
|
||||
CheckPoint checkPointCopy; /* copy of last check point record */
|
||||
|
||||
XLogRecPtr minRecoveryPoint; /* must replay xlog to here */
|
||||
/*
|
||||
* These two values determine the minimum point we must recover up to
|
||||
* before starting up:
|
||||
*
|
||||
* minRecoveryPoint is updated to the latest replayed LSN whenever we
|
||||
* flush a data change during archive recovery. That guards against
|
||||
* starting archive recovery, aborting it, and restarting with an earlier
|
||||
* stop location. If we've already flushed data changes from WAL record X
|
||||
* to disk, we mustn't start up until we reach X again. Zero when not
|
||||
* doing archive recovery.
|
||||
*
|
||||
* backupStartPoint is the redo pointer of the backup start checkpoint, if
|
||||
* we are recovering from an online backup and haven't reached the end of
|
||||
* backup yet. It is reset to zero when the end of backup is reached, and
|
||||
* we mustn't start up before that. A boolean would suffice otherwise, but
|
||||
* we use the redo pointer as a cross-check when we see an end-of-backup
|
||||
* record, to make sure the end-of-backup record corresponds the base
|
||||
* backup we're recovering from.
|
||||
*/
|
||||
XLogRecPtr minRecoveryPoint;
|
||||
XLogRecPtr backupStartPoint;
|
||||
|
||||
/*
|
||||
* This data is used to check for hardware-architecture compatibility of
|
||||
|
||||
Reference in New Issue
Block a user