PostgreSQL启动恢复期间,恢复到的时间线的确定

StartupXLOG->
 if (ControlFile->minRecoveryPointTLI >
  ControlFile->checkPointCopy.ThisTimeLineID)
  recoveryTargetTLI = ControlFile->minRecoveryPointTLI;
 else
  recoveryTargetTLI = 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;
   else
    rtli = (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;
  }
 }

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/51e602ef3d5ade7c054ef3de6735f4f3.html