初步学习pg_control文件之六
接前文:初步学习pg_control文件之五 ,DB_IN_ARCHIVE_RECOVERY何时出现?
看代码:如果recovery.conf文件存在,则返回 InArchiveRecovery = true。
/*
* See if there is a recovery command file (recovery.conf), and if so
* read in parameters for archive recovery and XLOG streaming.
* The file is parsed using the main configuration parser.
*/
static void
readRecoveryCommandFile(void)
{
…
fd = AllocateFile(RECOVERY_COMMAND_FILE, "r");
if (fd == NULL)
{
if (errno == ENOENT)
return; /* not there, so no archive recovery */
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not open recovery command file \"%s\": %m",
RECOVERY_COMMAND_FILE)));
}
… /* Enable fetching from archive recovery area */
InArchiveRecovery = true; …
}
然后,如果pg_control文件的state不是 DB_SHUTDOWNED状态,则可以认为需要recovery,
此时,如果 InArchiveRecovery 为true,则开始设置DB_IN_ARCHIVE_RECOVERY 状态。
/*
* This must be called ONCE during postmaster or standalone-backend startup
*/
void
StartupXLOG(void)
{
… /*
* Check for recovery control file, and if so set up state for offline
* recovery
*/
readRecoveryCommandFile(); … /*
* Check whether we need to force recovery from WAL. If it appears to
* have been a clean shutdown and we did not have a recovery.conf file,
* then assume no recovery needed.
*/
if (XLByteLT(checkPoint.redo, RecPtr))
{
if (wasShutdown)
ereport(PANIC,
(errmsg("invalid redo record in shutdown checkpoint")));
InRecovery = true;
}
else if (ControlFile->state != DB_SHUTDOWNED)
InRecovery = true;
else if (InArchiveRecovery)
{
/* force recovery due to presence of recovery.conf */
InRecovery = true;
} /* REDO */
if (InRecovery)
{
int rmid; /* use volatile pointer to prevent code rearrangement */
volatile XLogCtlData *xlogctl = XLogCtl; /*
* Update pg_control to show that we are recovering and to show the
* selected checkpoint as the place we are starting from. We also mark
* pg_control with any minimum recovery stop point obtained from a
* backup history file.
*/
if (InArchiveRecovery)
ControlFile->state = DB_IN_ARCHIVE_RECOVERY;
else
{
ereport(LOG,
(errmsg("database system was not properly shut down; "
automatic recovery in progress)));
ControlFile->state = DB_IN_CRASH_RECOVERY;
} …
UpdateControlFile();
…
}
… }
初步学习pg_control文件之六的更多相关文章
- 初步学习pg_control文件之七
接前文 初步学习pg_control文件之六 看 pg_control_version 以PostgreSQL9.1.1为了,其HISTORY文件中有如下的内容: Release Release ...
- 初步学习pg_control文件之十五
接前文 初步学习pg_control文件之十四 再看如下这个: int MaxConnections; 应该说,它是一个参考值,在global.c中有如下定义 /* * Primary determ ...
- 初步学习pg_control文件之十四
接前文 初步学习pg_control文件之十三 看如下几个: /* * Parameter settings that determine if the WAL can be used for arc ...
- 初步学习pg_control文件之十三
接前文,初步学习pg_control文件之十二 看这个: * backupStartPoint is the redo pointer of the backup start checkpoint, ...
- 初步学习pg_control文件之十二
接前问,初步学习pg_control文件之十一,再来看下面这个 XLogRecPtr minRecoveryPoint; 看其注释: * minRecoveryPoint is updated to ...
- 初步学习pg_control文件之十一
接前文 初步学习pg_control文件之十,再看这个 XLogRecPtr prevCheckPoint; /* previous check point record ptr */ 发生了che ...
- 初步学习pg_control文件之十
接前文 初步学习pg_control文件之九 看下面这个 XLogRecPtr checkPoint; /* last check point record ptr */ 看看这个pointer究竟保 ...
- 初步学习pg_control文件之九
接前文,初步学习pg_control文件之八 来看这个: pg_time_t time; /* time stamp of last pg_control update */ 当初初始化的时候,是这样 ...
- 初步学习pg_control文件之八
接前文 初步学习pg_control文件之七 继续 看:catalog_version_no 代码如下: static void WriteControlFile(void) { ... /* * ...
随机推荐
- linux下安装jdk和配置环境变量
参考博文:http://www.cnblogs.com/samcn/archive/2011/03/16/1986248.html 系统环境:linux centos 6.4_x64 软件版本:jdk ...
- IOS CoreLocation框架的使用(用于地理定位)
● 在移动互联网时代,移动app能解决用户的很多生活琐事,比如 ● 导航:去任意陌生的地方 ● 周边:找餐馆.找酒店.找银行.找电影院 ● 在上述应用中,都用到了地图和定位功能,在iOS开发中 ...
- Android(java)学习笔记56:Android InputMethodManager输入法简介
参见博客: http://blog.csdn.net/pi9nc/article/details/9196779
- 初学Pollard Rho算法
前言 \(Pollard\ Rho\)是一个著名的大数质因数分解算法,它的实现基于一个神奇的算法:\(MillerRabin\)素数测试(关于\(MillerRabin\),可以参考这篇博客:初学Mi ...
- HDU 2586 How far away ?【LCA】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=2586 How far away ? Time Limit: 2000/1000 MS (Java/Oth ...
- ConcurrentMap注意事项
java.util.concurrent.ConcurrentMap接口和ConcurrentHashMap实现类 只能在键不存在时将元素加入到map中, 只有在键存在并映射到特定值时才能从map中删 ...
- MVC学习六:Razor布局视图之【/Views/Shared/_Layout.cshtml】
_Layout代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> ...
- JavaEE权限管理系统的搭建(六)--------使用拦截器实现菜单URL的跳转权限验证和页面的三级菜单权限按钮显示
本小结讲解,点击菜单进行页面跳转,看下图,点击管理员列表后会被认证拦截器首先拦截,验证用户是否登录,如果登录就放行,紧接着会被权限验证拦截器再次拦截,拦截的时候,会根据URL地址上找到对应的方法,然后 ...
- PL/SQL知识点
1.ROW_NUMBER() OVER(PARTITION BY XXX ORDER BY XXX) SELECT STP.FLOW_INST_ID, BUU.USER_NAME, ORGG.NAME ...
- python学习笔记--数据类型
Life is short, You need Python! 霸气的口号! 今天我也开始学python了,毕竟不懂后端的前端不是好前端.之前有过‘世界上最好的语言’和JavaScript的学习经验. ...