Обсуждение: stopping server does not remove external_pid_file
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 --=20 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?
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/
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
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. +
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
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. +
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
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]. 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/