溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

PostgreSQL問題分析1:時(shí)間線不一致

發(fā)布時(shí)間:2020-07-11 19:18:50 來源:網(wǎng)絡(luò) 閱讀:1091 作者:yzs的專欄 欄目:數(shù)據(jù)庫

一、問題:requested timeline %u does not contain minimum recovery point %X/%X on timeline %u

該日志在代碼中的位置如下:

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)));

二、分析

recoveryTargetTLI這個(gè)值是什么呢?

1、改值在啟動(dòng)恢復(fù)過程中變化如下:

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文件記錄的最小恢復(fù)點(diǎn)時(shí)間線ControlFile->minRecoveryPointTLI會(huì)和pg_control文件記錄的checkpoint的的時(shí)間線?ControlFile->checkPointCopy.ThisTimeLineID比較,recoveryTargetTLI取兩者之間較大值。

然后readRecoveryCommandFile會(huì)讀取recovery.cnf文件,如果是主機(jī)則沒有recovery.cnf文件。recovery.cnf文件中recovery_target_timeline的值指定恢復(fù)到的時(shí)間線,如果是latest則時(shí)間線rtli為0否則為其指定值;如果rtli是指定值,則recoveryTargetTLI為指定值,否則從第一步獲取的recoveryTargetTLI值+1開始,看是否有其對(duì)于的history文件,找到最大時(shí)間線對(duì)于的history文件,recoveryTargetTLI為該時(shí)間線。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI