stopping server does not remove external_pid_file

Started by Martin Pittalmost 20 years ago8 messagesbugs
Jump to latest
#1Martin Pitt
martin@piware.de

Hi PostgreSQL developers,

I just played around with external_pid_file in 8.1.4. I noticed that
the file is created and filled properly, but it is not removed again
when the server is stopped.

Thank you,

Martin
--
Martin Pitt http://www.piware.de
Ubuntu Developer http://www.ubuntu.com
Debian Developer http://www.debian.org

In a world without walls and fences, who needs Windows and Gates?

In reply to: Martin Pitt (#1)
Re: stopping server does not remove external_pid_file

Martin Pitt wrote:

I just played around with external_pid_file in 8.1.4. I noticed that
the file is created and filled properly, but it is not removed again
when the server is stopped.

Looking at the code I see this comment in
src/backend/postmaster/postmaster.c

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

IMHO, yes. It's not useful anymore.

Maybe some simple test in pmdie(). I'm too tired to code something now.
:(

--
Euler Taveira de Oliveira
http://www.timbira.com/

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Euler Taveira de Oliveira (#2)
Re: stopping server does not remove external_pid_file

Euler Taveira de Oliveira <euler@timbira.com> writes:

Martin Pitt wrote:

I just played around with external_pid_file in 8.1.4. I noticed that
the file is created and filled properly, but it is not removed again
when the server is stopped.

Looking at the code I see this comment in
src/backend/postmaster/postmaster.c

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

IMHO, yes. It's not useful anymore.

[ shrug... ] If the postmaster crashes, it would certainly fail to
remove the pidfile. So I'd argue that your unnamed external script
that is expecting the pidfile to go away needs work: if it's not
verifying the PID given in the file, it's broken.

regards, tom lane

#4Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#3)
Re: stopping server does not remove external_pid_file

Tom Lane wrote:

Euler Taveira de Oliveira <euler@timbira.com> writes:

Martin Pitt wrote:

I just played around with external_pid_file in 8.1.4. I noticed that
the file is created and filled properly, but it is not removed again
when the server is stopped.

Looking at the code I see this comment in
src/backend/postmaster/postmaster.c

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

IMHO, yes. It's not useful anymore.

[ shrug... ] If the postmaster crashes, it would certainly fail to
remove the pidfile. So I'd argue that your unnamed external script
that is expecting the pidfile to go away needs work: if it's not
verifying the PID given in the file, it's broken.

Doesn't removing the file reduce the chances of failing to start later
in case another postmaster already has that pid? Why do we keep it
around?

--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#4)
Re: stopping server does not remove external_pid_file

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Doesn't removing the file reduce the chances of failing to start later
in case another postmaster already has that pid?

No, because the external pidfile has zero to do with Postgres' internal
behavior.

Personally I always thought that the external pidfile was a "feature"
we should have rejected. It can never be a particularly reliable guide
to what PG is doing, the more especially so if the program looking at it
isn't doing any cross-checking, as the OP seems not to be doing.

regards, tom lane

#6Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#5)
Re: stopping server does not remove external_pid_file

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Doesn't removing the file reduce the chances of failing to start later
in case another postmaster already has that pid?

No, because the external pidfile has zero to do with Postgres' internal
behavior.

Personally I always thought that the external pidfile was a "feature"
we should have rejected. It can never be a particularly reliable guide
to what PG is doing, the more especially so if the program looking at it
isn't doing any cross-checking, as the OP seems not to be doing.

Oh, it is the "external" file, not the one we automatically create in the
/data directory.

--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#7Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: Tom Lane (#5)
Re: stopping server does not remove external_pid_file

On Tue, Jun 06, 2006 at 11:32:53PM -0400, Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Doesn't removing the file reduce the chances of failing to start later
in case another postmaster already has that pid?

No, because the external pidfile has zero to do with Postgres' internal
behavior.

Personally I always thought that the external pidfile was a "feature"
we should have rejected. It can never be a particularly reliable guide
to what PG is doing, the more especially so if the program looking at it
isn't doing any cross-checking, as the OP seems not to be doing.

Has anyone considered allowing $PGDATA to be mode 701 and our pid file
being 644? ISTM that would remove the need for external_pid_file, though
of course people would still need to do the same kinds of checking.

Even if they do need to do the checking though, ISTM it'd be better to
remove the external PID file on shutdown...
--
Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In reply to: Tom Lane (#5)
Re: stopping server does not remove external_pid_file

Tom Lane wrote:

No, because the external pidfile has zero to do with Postgres' internal
behavior.

+1. So we have two options: have external_pid_file mimics the internal
behavior or deprecates it.

I couldn't find the discussion about it; just the patch [1]http://archives.postgresql.org/pgsql-patches/2004-06/msg00006.php. IIRC this
'feature' was proposed to permit another home to postmaster.pid file. Am
I wrong? But seems to duplicate the pid file information.

[1]: http://archives.postgresql.org/pgsql-patches/2004-06/msg00006.php

--
Euler Taveira de Oliveira
http://www.timbira.com/