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;                        
        …                        
    }                            
  • 相关阅读:
    opencv和linux的关联
    附加数据库 对于server XXX失败
    android.app.Dialog(23)里window的那些事(坑)
    hdu 4722 Good Numbers(数位dp)
    Java程序猿必知的10个调试技巧
    iir调试记录
    在Scope利用Content sharing Widget来分享内容
    JavaEE 技术选型建议,server配置,部署策略
    x265探索与研究(四):怎样编码视频?
    计算git树上随意两点的近期切割点。
  • 原文地址:https://www.cnblogs.com/gaojian/p/3227684.html
Copyright © 2011-2022 走看看