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;                        
        …                        
    }                            
  • 相关阅读:
    CPU die
    删除binlog的方法
    mysql中bigint、int、mediumint、smallint 和 tinyint的取值范围
    Javascript中的Keycode值列表
    php5.2转向 PHP 5.3 的 PHP 开发
    linux 下查看系统内存使用情况的方法
    Kyoto Cabinet(DBM) + Kyoto Tycoon(网络层)
    window 7 下一台cp 两个mysql 配置主从
    php 序列化(serialize)格式详解
    Linux下ntpdate时间同步
  • 原文地址:https://www.cnblogs.com/gaojian/p/3227684.html
Copyright © 2011-2022 走看看