summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-03-07 12:12:33 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-03-07 12:12:33 +0200
commitd009f9036d62762b6a261055e7417ae911233853 (patch)
tree204497ac11f6334392b1b3cd8c908d5f926777cd /src
parentc52ba36bd78a6e67d0ac30de8c71fb256cbaf026 (diff)
Further fix to the mode where we enter archive recovery after crash recovery.
I missed to returns in the middle of ReadRecord function in my previous fix. If a WAL file was not found at all during crash recovery, XLogPageRead would return 'false', and ReadRecord would return without entering archive recovery. 9.2 only. In master, the code is structured differently and does not have this problem. Kyotaro HORIGUCHI, Mitsumasa KONDO and me.
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/transam/xlog.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 92adc4e9fed..0666a883eaf 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -4010,7 +4010,16 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt)
retry:
/* Read the page containing the record */
if (!XLogPageRead(RecPtr, emode, fetching_ckpt, randAccess))
- return NULL;
+ {
+ /*
+ * In standby-mode, XLogPageRead returning false means that promotion
+ * has been triggered.
+ */
+ if (StandbyMode)
+ return NULL;
+ else
+ goto next_record_is_invalid;
+ }
pageHeaderSize = XLogPageHeaderSize((XLogPageHeader) readBuf);
targetRecOff = RecPtr->xrecoff % XLOG_BLCKSZ;
@@ -4168,7 +4177,16 @@ retry:
}
/* Wait for the next page to become available */
if (!XLogPageRead(&pagelsn, emode, false, false))
- return NULL;
+ {
+ /*
+ * In standby-mode, XLogPageRead returning false means that
+ * promotion has been triggered.
+ */
+ if (StandbyMode)
+ return NULL;
+ else
+ goto next_record_is_invalid;
+ }
/* Check that the continuation record looks valid */
if (!(((XLogPageHeader) readBuf)->xlp_info & XLP_FIRST_IS_CONTRECORD))
@@ -10326,6 +10344,9 @@ CancelBackup(void)
* and call XLogPageRead() again with the same arguments. This lets
* XLogPageRead() to try fetching the record from another source, or to
* sleep and retry.
+ *
+ * In standby mode, this only returns false if promotion has been triggered.
+ * Otherwise it keeps sleeping and retrying indefinitely.
*/
static bool
XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt,