zoukankan      html  css  js  c++  java
  • 对Postmaster 对 SIGQUIT 信号处理的理解

    [作者:技术者高健@博客园  mail: luckyjackgao@gmail.com ]

    Postmaster 作为父进程,要对很多子进程进行监控,当遇到各种信号的时候,也要适当地进行传达。

    /*                                
     * pmdie -- signal handler for processing various postmaster signals.                                
     */                                
    static void                                
    pmdie(SIGNAL_ARGS)                                
    {                                
        int            save_errno = errno;                
                                    
        PG_SETMASK(&BlockSig);                            
                                    
        ereport(DEBUG2,                            
                (errmsg_internal("postmaster received signal %d",                    
                                 postgres_signal_arg)));    
                                    
        switch (postgres_signal_arg)                            
        {                            
            ……                        
            case SIGQUIT:                        
                                    
                /*                    
                 * Immediate Shutdown:                    
                 *                    
                 * abort all children with SIGQUIT and exit without attempt to                    
                 * properly shut down data base system.                    
                 */                    
                ereport(LOG,                    
                        (errmsg("received immediate shutdown request")));            
                SignalChildren(SIGQUIT);                    
                if (StartupPID != 0)                    
                    signal_child(StartupPID, SIGQUIT);                
                if (BgWriterPID != 0)                    
                    signal_child(BgWriterPID, SIGQUIT);                
                if (CheckpointerPID != 0)                    
                    signal_child(CheckpointerPID, SIGQUIT);                
                if (WalWriterPID != 0)                    
                    signal_child(WalWriterPID, SIGQUIT);                
                if (WalReceiverPID != 0)                    
                    signal_child(WalReceiverPID, SIGQUIT);                
                if (AutoVacPID != 0)                    
                    signal_child(AutoVacPID, SIGQUIT);                
                if (PgArchPID != 0)                    
                    signal_child(PgArchPID, SIGQUIT);                
                if (PgStatPID != 0)                    
                    signal_child(PgStatPID, SIGQUIT);                
                ExitPostmaster(0);                    
                break;                    
        }                            
                                    
        PG_SETMASK(&UnBlockSig);                            
                                    
        errno = save_errno;                            
    }                                

    实验验证:

    启动:

    [postgres@localhost bin]$ ./postgres -D /usr/local/pgsql/data
    LOG:  database system was shut down at 2012-10-31 15:19:46 CST
    LOG:  autovacuum launcher started
    LOG:  database system is ready to accept connections

    发信号:

    [postgres@localhost bin]$ ./pg_ctl -D /usr/local/pgsql/data stop -m immediate
    waiting for server to shut down.... done
    server stopped
    [postgres@localhost bin]$ 

    后台出现的信息是:

    LOG:  received immediate shutdown request
    bg_quickdie happend.
    WARNING:  terminating connection because of crash of another server process
    DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
    HINT:  In a moment you should be able to reconnect to the database and repeat your command.

    [作者:技术者高健@博客园  mail: luckyjackgao@gmail.com ]

    结束

  • 相关阅读:
    raw_input() 与 input()对比
    你很熟悉CSS,却没掌握这些CSS技巧
    CSS样式设置
    javascript基本语法和变量(转)
    手机/移动前端开发需要注意的20个要点
    移动端”宴席知多少
    git第一次提交代码到远程仓库
    java对过反射调用方法
    站点收集
    别人抢红包,我们研究一下红包算法
  • 原文地址:https://www.cnblogs.com/gaojian/p/2748143.html
Copyright © 2011-2022 走看看