zoukankan      html  css  js  c++  java
  • 初步学习pg_control文件之四

    接前文,初步学习pg_control文件之三  继续分析

    何时出现 DB_SHUTDOWNING状态:

    在正常的shutdown的时候,需要进行checkpoint,所以就在此处,设置pg_control文件的state状态为DB_SHUTDOWNING。

    /*
     * Perform a checkpoint --- either during shutdown, or on-the-fly
     *
     * flags is a bitwise OR of the following:
     *    CHECKPOINT_IS_SHUTDOWN: checkpoint is for database shutdown.
     *    CHECKPOINT_END_OF_RECOVERY: checkpoint is for end of WAL recovery.
     *    CHECKPOINT_IMMEDIATE: finish the checkpoint ASAP,
     *        ignoring checkpoint_completion_target parameter.
     *    CHECKPOINT_FORCE: force a checkpoint even if no XLOG activity has occured
     *        since the last one (implied by CHECKPOINT_IS_SHUTDOWN or
     *        CHECKPOINT_END_OF_RECOVERY).
     *
     * Note: flags contains other bits, of interest here only for logging purposes.
     * In particular note that this routine is synchronous and does not pay
     * attention to CHECKPOINT_WAIT.
     */
    void
    CreateCheckPoint(int flags)
    {
        ...
        if (shutdown)
        {
            LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);
            ControlFile->state = DB_SHUTDOWNING;
            ControlFile->time = (pg_time_t) time(NULL);
            UpdateControlFile();
            LWLockRelease(ControlFileLock);
        }
        ...
    }

    更进一步地说,是这样的:先是Shutdowning, 后来就变化为Shutdowned

    /*                            
     * Perform a checkpoint --- either during shutdown, or on-the-fly                            
     *                            
     * flags is a bitwise OR of the following:                            
     *    CHECKPOINT_IS_SHUTDOWN: checkpoint is for database shutdown.                        
     *    CHECKPOINT_END_OF_RECOVERY: checkpoint is for end of WAL recovery.                        
     *    CHECKPOINT_IMMEDIATE: finish the checkpoint ASAP,                        
     *        ignoring checkpoint_completion_target parameter.                    
     *    CHECKPOINT_FORCE: force a checkpoint even if no XLOG activity has occured                        
     *        since the last one (implied by CHECKPOINT_IS_SHUTDOWN or                    
     *        CHECKPOINT_END_OF_RECOVERY).                    
     *                            
     * Note: flags contains other bits, of interest here only for logging purposes.                            
     * In particular note that this routine is synchronous and does not pay                            
     * attention to CHECKPOINT_WAIT.                            
     */                            
    void                            
    CreateCheckPoint(int flags)                            
    {                            
        …                        
                                
        if (shutdown)                        
        {                        
            LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);                    
            ControlFile->state = DB_SHUTDOWNING;                    
            ControlFile->time = (pg_time_t) time(NULL);                    
            UpdateControlFile();                    
            LWLockRelease(ControlFileLock);                    
        }                        
        …                        
                                
        /*                        
         * Update the control file.                        
         */                        
        LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);                        
        if (shutdown)                        
            ControlFile->state = DB_SHUTDOWNED;                    
                                
        ControlFile->prevCheckPoint = ControlFile->checkPoint;                        
        …                        
    }                            
  • 相关阅读:
    grep如何忽略.svn目录,以及如何忽略多个目录
    CSS写的提示框(兼容火狐IE等各大浏览器)
    校验IPv4和IPv6地址和URL地址
    input框设置onInput事件只能输入数字,能兼容火狐IE9
    $(function(){})、$(document).ready(function(){})....../ ready和onload的区别
    jQuery EasyUI 教程-Tooltip(提示框)
    小知识随手记(一)
    自动换行效果对比
    getComputedStyle与currentStyle获取样式(style/class)
    弹出层框架layer快速使用
  • 原文地址:https://www.cnblogs.com/gaojian/p/3227684.html
Copyright © 2011-2022 走看看