標籤:rom style 最大的 時間 ttl find ntc head start
1、啟動恢複時,確定恢複到的時間軸recoveryTargetTLI
1)歸檔復原點比checkpoint中記錄的時間軸大,那麼選擇歸檔復原點作為目標時間軸
2)否則,checkpoint記錄中的時間軸作為目標時間軸
StartupXLOG->if (ControlFile->minRecoveryPointTLI >ControlFile->checkPointCopy.ThisTimeLineID)recoveryTargetTLI = ControlFile->minRecoveryPointTLI;elserecoveryTargetTLI = ControlFile->checkPointCopy.ThisTimeLineID;...
2、接著從recovery.conf檔案中讀取
1)若設定了recovery_target_timeline值,並且設為latest,那麼history列表最大的時間軸即為目標時間軸
2)否則是recovery.conf檔案中設定的時間軸值
3)若沒有設定recovery_target_timeline值,則目標時間軸為第一步中的值
StartupXLOG->readRecoveryCommandFile()->for (item = head; item; item = item->next){if (strcmp(item->name, "restore_command") == 0){...}else if ...else if(strcmp(item->name, "recovery_target_timeline") == 0){rtliGiven = true;if (strcmp(item->value, "latest") == 0)rtli = 0;elsertli = (TimeLineID) strtoul(item->value, NULL, 0);}else if...}if (rtliGiven){if (rtli){recoveryTargetTLI = rtli;recoveryTargetIsLatest = false;}else{/* We start the "latest" search from pg_control's timeline */recoveryTargetTLI = findNewestTimeLine(recoveryTargetTLI);recoveryTargetIsLatest = true;}}
PostgreSQL啟動恢複期間,恢複到的時間軸的確定