Skip to content

Commit d009f90

Browse files
committed
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.
1 parent c52ba36 commit d009f90

File tree

1 file changed

+23
-2
lines changed
  • src/backend/access/transam

1 file changed

+23
-2
lines changed

src/backend/access/transam/xlog.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4010,7 +4010,16 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt)
40104010
retry:
40114011
/* Read the page containing the record */
40124012
if (!XLogPageRead(RecPtr, emode, fetching_ckpt, randAccess))
4013-
return NULL;
4013+
{
4014+
/*
4015+
* In standby-mode, XLogPageRead returning false means that promotion
4016+
* has been triggered.
4017+
*/
4018+
if (StandbyMode)
4019+
return NULL;
4020+
else
4021+
goto next_record_is_invalid;
4022+
}
40144023

40154024
pageHeaderSize = XLogPageHeaderSize((XLogPageHeader) readBuf);
40164025
targetRecOff = RecPtr->xrecoff % XLOG_BLCKSZ;
@@ -4168,7 +4177,16 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt)
41684177
}
41694178
/* Wait for the next page to become available */
41704179
if (!XLogPageRead(&pagelsn, emode, false, false))
4171-
return NULL;
4180+
{
4181+
/*
4182+
* In standby-mode, XLogPageRead returning false means that
4183+
* promotion has been triggered.
4184+
*/
4185+
if (StandbyMode)
4186+
return NULL;
4187+
else
4188+
goto next_record_is_invalid;
4189+
}
41724190

41734191
/* Check that the continuation record looks valid */
41744192
if (!(((XLogPageHeader) readBuf)->xlp_info & XLP_FIRST_IS_CONTRECORD))
@@ -10326,6 +10344,9 @@ CancelBackup(void)
1032610344
* and call XLogPageRead() again with the same arguments. This lets
1032710345
* XLogPageRead() to try fetching the record from another source, or to
1032810346
* sleep and retry.
10347+
*
10348+
* In standby mode, this only returns false if promotion has been triggered.
10349+
* Otherwise it keeps sleeping and retrying indefinitely.
1032910350
*/
1033010351
static bool
1033110352
XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt,

0 commit comments

Comments
 (0)