aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2011-08-10 09:16:29 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2011-08-10 09:22:49 +0300
commit41f9ffd928b6fdcedd685483e777b0fa71ece47c (patch)
treea5fb89c11e0df78c5cff40b4ec7bbcc76b8841e5 /src/include
parent9f17ffd8660243382809b8023ff3d38fbfac4e8b (diff)
downloadpostgresql-41f9ffd928b6fdcedd685483e777b0fa71ece47c.tar.gz
postgresql-41f9ffd928b6fdcedd685483e777b0fa71ece47c.zip
If backup-end record is not seen, and we reach end of recovery from a
streamed backup, throw an error and refuse to start up. The restore has not finished correctly in that case and the data directory is possibly corrupt. We already errored out in case of archive recovery, but could not during crash recovery because we couldn't distinguish between the case that pg_start_backup() was called and the database then crashed (must not error, data is OK), and the case that we're restoring from a backup and not all the needed WAL was replayed (data can be corrupt). To distinguish those cases, add a line to backup_label to indicate whether the backup was taken with pg_start/stop_backup(), or by streaming (ie. pg_basebackup). This requires re-initdb, because of a new field added to the control file.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/pg_control.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/include/catalog/pg_control.h b/src/include/catalog/pg_control.h
index d543ef6e244..faf4de42440 100644
--- a/src/include/catalog/pg_control.h
+++ b/src/include/catalog/pg_control.h
@@ -21,7 +21,7 @@
/* Version identifier for this pg_control format */
-#define PG_CONTROL_VERSION 903
+#define PG_CONTROL_VERSION 911
/*
* Body of CheckPoint XLOG records. This is declared here because we keep
@@ -137,9 +137,16 @@ typedef struct ControlFileData
* 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.
+ *
+ * If backupEndRequired is true, we know for sure that we're restoring
+ * from a backup, and must see a backup-end record before we can safely
+ * start up. If it's false, but backupStartPoint is set, a backup_label
+ * file was found at startup but it may have been a leftover from a stray
+ * pg_start_backup() call, not accompanied by pg_stop_backup().
*/
XLogRecPtr minRecoveryPoint;
XLogRecPtr backupStartPoint;
+ bool backupEndRequired;
/*
* Parameter settings that determine if the WAL can be used for archival