Re: external_pid_file not removed on postmaster exit

Lists: pgsql-hackers
From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: external_pid_file not removed on postmaster exit
Date: 2012-07-27 05:09:10
Message-ID: 1343365750.31795.3.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

It seems strange that the external_pid_file is never removed. There is
even a C comment about it:

/* Should we remove the pid file on postmaster exit? */

I think it should be removed with proc_exit hook just like the main
postmaster.pid file.

Does anyone remember why this was not done originally or have any
concerns?


From: Amit kapila <amit(dot)kapila(at)huawei(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: external_pid_file not removed on postmaster exit
Date: 2012-07-28 07:41:49
Message-ID: 6C0B27F7206C9E4CA54AE035729E9C382851FB0E@szxeml509-mbs
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>From: pgsql-hackers-owner(at)postgresql(dot)org [pgsql-hackers-owner(at)postgresql(dot)org] on behalf of Peter Eisentraut [peter_e(at)gmx(dot)net]
> Sent: Friday, July 27, 2012 10:39 AM

> It seems strange that the external_pid_file is never removed. There is
> even a C comment about it:

> /* Should we remove the pid file on postmaster exit? */

> I think it should be removed with proc_exit hook just like the main
> postmaster.pid file.

external_pid_file is created first time when it is enabled in postgresql.conf
I think it should be removed once the parameter external_pid_file is unset;

Making handling of both postmaster.pid and external_pid_file same in terms of creation and removal may not be best choice
as both have different purpose.

With Regards,
Amit Kapila.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Amit kapila <amit(dot)kapila(at)huawei(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: external_pid_file not removed on postmaster exit
Date: 2012-07-28 16:16:59
Message-ID: 177.1343492219@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Amit kapila <amit(dot)kapila(at)huawei(dot)com> writes:
>> I think it should be removed with proc_exit hook just like the main
>> postmaster.pid file.

> external_pid_file is created first time when it is enabled in postgresql.conf
> I think it should be removed once the parameter external_pid_file is unset;

Unset? If that parameter is not PGC_POSTMASTER, it certainly ought to
be. In any case, that has little to do with what Peter is complaining
about ...

regards, tom lane


From: Amit kapila <amit(dot)kapila(at)huawei(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: external_pid_file not removed on postmaster exit
Date: 2012-07-29 05:00:20
Message-ID: 6C0B27F7206C9E4CA54AE035729E9C382851FB76@szxeml509-mbs
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> From: Tom Lane [tgl(at)sss(dot)pgh(dot)pa(dot)us]
> Sent: Saturday, July 28, 2012 9:46 PM
Amit kapila <amit(dot)kapila(at)huawei(dot)com> writes:
>>> I think it should be removed with proc_exit hook just like the main
>>> postmaster.pid file.

>> external_pid_file is created first time when it is enabled in postgresql.conf
>> I think it should be removed once the parameter external_pid_file is unset;

> Unset?
By Unset, I mean to say when the configuration parameter 'external_pid_file' is disabled (#external_pid_file).
But if the path/filename is changed to different name across restart of server, it will not be able to delete the previous file.
So it will not workout the way I was trying to think.

However if it is deleted at proc_exit as suggested by Peter, there will be no problem.

The reason why I have thought the file not to get deleted at every proc_exit, is
a. Initially I thought it might be un-necessary to delete and re-create the file at server shutdown and start.
b. I was not sure if this file has usage only till server is running.

With Regards,
Amit Kapila.


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: external_pid_file not removed on postmaster exit
Date: 2012-08-17 05:43:21
Message-ID: 1345182201.19882.1.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 2012-07-27 at 08:09 +0300, Peter Eisentraut wrote:
> It seems strange that the external_pid_file is never removed. There is
> even a C comment about it:
>
> /* Should we remove the pid file on postmaster exit? */
>
> I think it should be removed with proc_exit hook just like the main
> postmaster.pid file.
>
> Does anyone remember why this was not done originally or have any
> concerns?

Since that was not the case, I propose the attached patch to unlink the
external pid file.

Attachment Content-Type Size
pg-unlink-external-pid-file.patch text/x-patch 1.5 KB