1、問題:requested timeline %u does not contain minimum recovery point %X/%X on timeline %uide
該日誌在代碼中的位置以下:ui
StartupXLOG: if (!XLogRecPtrIsInvalid(ControlFile->minRecoveryPoint) && tliOfPointInHistory(ControlFile->minRecoveryPoint - 1, expectedTLEs) != ControlFile->minRecoveryPointTLI) ereport(FATAL, (errmsg("requested timeline %u does not contain minimum recovery point %X/%X on timeline %u", recoveryTargetTLI, (uint32) (ControlFile->minRecoveryPoint >> 32), (uint32) ControlFile->minRecoveryPoint, ControlFile->minRecoveryPointTLI)));
2、分析日誌
recoveryTargetTLI這個值是什麼呢?code
一、改值在啓動恢復過程當中變化以下:get
StartupXLOG: ... if (ControlFile->minRecoveryPointTLI > ControlFile->checkPointCopy.ThisTimeLineID) recoveryTargetTLI = ControlFile->minRecoveryPointTLI; else recoveryTargetTLI = ControlFile->checkPointCopy.ThisTimeLineID; readRecoveryCommandFile(); |-- for (item = head; item; item = item->next){ | ... | else if (strcmp(item->name, "recovery_target_timeline") == 0){ | rtliGiven = true; | if (strcmp(item->value, "latest") == 0) | rtli = 0; | else | rtli = (TimeLineID) strtoul(item->value, NULL, 0); | } | ... | } | ... | if (rtliGiven){ | if (rtli){ | recoveryTargetTLI = rtli; | recoveryTargetIsLatest = false; | }else{ | recoveryTargetTLI = findNewestTimeLine(recoveryTargetTLI); | recoveryTargetIsLatest = true; | } |-- }
首先,pg_control文件記錄的最小恢復點時間線ControlFile->minRecoveryPointTLI會和pg_control文件記錄的checkpoint的的時間線 ControlFile->checkPointCopy.ThisTimeLineID比較,recoveryTargetTLI取二者之間較大值。it
而後readRecoveryCommandFile會讀取recovery.cnf文件,若是是主機則沒有recovery.cnf文件。recovery.cnf文件中recovery_target_timeline的值指定恢復到的時間線,若是是latest則時間線rtli爲0不然爲其指定值;若是rtli是指定值,則recoveryTargetTLI爲指定值,不然從第一步獲取的recoveryTargetTLI值+1開始,看是否有其對於的history文件,找到最大時間線對於的history文件,recoveryTargetTLI爲該時間線。class