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
----------------------------------------------------
复制代码






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值