zoukankan      html  css  js  c++  java
  • PostgreSQL神秘进程的观察

    在PostgreSQL运行的时候,通过对其代码进行跟踪,发现不断有进程被生成,访问InitFileAccess,过了大约20秒左右,就死掉了。

    这个过程反复地进行着,进程号不断增加。

    我对其进一步进行了跟踪,发现似乎是这些进程是为了 autovacuum 而被创建出来,然后自己消亡的。

    在PostgreSQL9.2源代码中加入:

    InitFileAccess(void)
    {
    
        fprintf(stderr,"In %s ...by Process %d\n", __FUNCTION__,getpid());
        fprintf(stderr,"----------------------------------------------------\n\n");
    
        ...
    }
    void
    BaseInit(void)
    {
    
        fprintf(stderr,"In %s ...by Process %d\n", __FUNCTION__,getpid());
    
        /*
         * Attach to shared memory and semaphores, and initialize our
         * input/output/debugging file descriptors.
         */
        InitCommunication();
        DebugFileOpen();
    
        /* Do local initialization of file, storage and buffer managers */
        InitFileAccess();
        smgrinit();
        InitBufferPoolAccess();
    }
    NON_EXEC_STATIC void
    AutoVacLauncherMain(int argc, char *argv[])
    {
        ...
        fprintf(stderr,"In %s ...by Process %d\n", __FUNCTION__,getpid());
    
        /* Early initialization */
        BaseInit();
        ...
        proc_exit(0);                /* done */
    }
    NON_EXEC_STATIC void
    AutoVacWorkerMain(int argc, char *argv[])
    {
        ...
        fprintf(stderr,"In %s ...by Process %d\n", __FUNCTION__,getpid());
    
        /* Early initialization */
        BaseInit();
        ...
    
        /* All done, go away */
        proc_exit(0);
    }

    执行结果如下:

    [postgres@lex bin]$ ./pg_ctl -D ../data start
    server starting
    [postgres@lex bin]$ In BaseInit ...by Process 4804
    In InitFileAccess ...by Process 4804
    ----------------------------------------------------
    
    LOG:  database system was shut down at 2013-05-24 14:29:46 CST
    In BaseInit ...by Process 4805
    In InitFileAccess ...by Process 4805
    ----------------------------------------------------
    
    In BaseInit ...by Process 4806
    In InitFileAccess ...by Process 4806
    ----------------------------------------------------
    
    In BaseInit ...by Process 4807
    In InitFileAccess ...by Process 4807
    ----------------------------------------------------
    
    LOG:  autovacuum launcher started
    In AutoVacLauncherMain ...by Process 4808
    In BaseInit ...by Process 4808
    In InitFileAccess ...by Process 4808
    ----------------------------------------------------
    
    LOG:  database system is ready to accept connections
    In AutoVacWorkerMain ...by Process 4816
    In BaseInit ...by Process 4816
    In InitFileAccess ...by Process 4816
    ----------------------------------------------------
    
    In AutoVacWorkerMain ...by Process 4823
    In BaseInit ...by Process 4823
    In InitFileAccess ...by Process 4823
    ----------------------------------------------------
    
    In AutoVacWorkerMain ...by Process 4830
    In BaseInit ...by Process 4830
    In InitFileAccess ...by Process 4830
    ----------------------------------------------------
  • 相关阅读:
    python抢票开发——设备预约助手实现
    树莓派的基本网络配置
    python 端口扫描程序
    数据通讯与网络 第五版第24章 传输层协议-TCP协议部分要点
    数据通讯与网络 第五版第24章 传输层协议-UDP协议部分要点
    利用python开发的flappy bird 游戏
    EMACS 快捷键笔记
    python程序中用类变量代替global 定义全局变量
    在树莓派下对多个串口转USB设备进行设备名称绑定操作
    python 编写的经纬度坐标转换类
  • 原文地址:https://www.cnblogs.com/gaojian/p/3096879.html
Copyright © 2011-2022 走看看