PostgreSQL问题分析1:时间线不一致

发布时间:2020-07-11 19:18:50 作者:yzs的专栏
来源:网络 阅读:1067

一、问题: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这个值是什么呢?

1、改值在启动恢复过程中变化如下:

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取两者之间较大值。

然后readRecoveryCommandFile会读取recovery.cnf文件,如果是主机则没有recovery.cnf文件。recovery.cnf文件中recovery_target_timeline的值指定恢复到的时间线,如果是latest则时间线rtli为0否则为其指定值;如果rtli是指定值,则recoveryTargetTLI为指定值,否则从第一步获取的recoveryTargetTLI值+1开始,看是否有其对于的history文件,找到最大时间线对于的history文件,recoveryTargetTLI为该时间线。

推荐阅读:
  1. PostgreSQL启动恢复期间,恢复到的时间线的确定
  2. django开源项目bootcamp个别问题分析(1)

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

postgresql 时间线 gr

上一篇:Packet Tracer 6.2新特性

下一篇:Vue入门五、组件化开发

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》