日志源会在XLOG_FROM_ARCHIVE->XLOG_FROM_STREAM->XLOG_FROM_ARCHIVE直接切换,只有读取过程中出错,就会切换到另外一个日志源。但实际执行过程中,XLOG_FROM_ARCHIVE出错后会到XLOG_FROM_PG_WAL读取,但是日志源的变量并不会改变。这个需要注意。
static int
XLogFileReadAnyTLI(XLogSegNo segno, int emode, int source)
{
if (expectedTLEs)
tles = expectedTLEs;
else
tles = readTimeLineHistory(recoveryTargetTLI);
foreach(cell, tles){
TimeLineID tli = ((TimeLineHistoryEntry *) lfirst(cell))->tli;
if (tli < curFileTLI)
break;
if (source == XLOG_FROM_ANY || source == XLOG_FROM_ARCHIVE){
fd = XLogFileRead(segno, emode, tli,XLOG_FROM_ARCHIVE, true);
if (fd != -1){
if (!expectedTLEs)
expectedTLEs = tles;
return fd;
}
}
if (source == XLOG_FROM_ANY || source == XLOG_FROM_PG_WAL){
fd = XLogFileRead(segno, emode, tli, XLOG_FROM_PG_WAL, true);
if (fd != -1){
if (!expectedTLEs)
expectedTLEs = tles;
return fd;
}
}
}
return -1;
}