温馨提示×

温馨提示×

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

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

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

发布时间:2020-07-18 11:56:03 来源:网络 阅读:1266 作者:yzs的专栏 栏目:数据库

1、启动恢复时,确定恢复到的时间线recoveryTargetTLI

1)归档恢复点比checkpoint中记录的时间线大,那么选择归档恢复点作为目标时间线

2)否则,checkpoint记录中的时间线作为目标时间线

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


向AI问一下细节

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

AI