Thread: pid file for postmaster?

pid file for postmaster?

From
Tatsuo Ishii
Date:
Hi,

It would be nice if postmaster has its own pid file to send signals to
it. I think the pid file could be placed under $PGDATA. Opinions?
--
Tatsuo Ishii


Re: [HACKERS] pid file for postmaster?

From
Tom Lane
Date:
Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> It would be nice if postmaster has its own pid file to send signals to
> it. I think the pid file could be placed under $PGDATA. Opinions?

Yes, that's been discussed before, and I think it's even got an entry
on the TODO list.  If you've got time to tackle it now, great!

$PGDATA seems like the right place to put the file, since we can only
have one active postmaster at a time in a database directory.

I assume you'll also create a script that sends SIGTERM or other
requested signal to the postmaster, using this file?
        regards, tom lane


Re: [HACKERS] pid file for postmaster?

From
Tatsuo Ishii
Date:
From: Tom Lane <tgl@sss.pgh.pa.us>
> Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> > It would be nice if postmaster has its own pid file to send signals to
> > it. I think the pid file could be placed under $PGDATA. Opinions?
> 
> Yes, that's been discussed before, and I think it's even got an entry
> on the TODO list.  If you've got time to tackle it now, great!
> 
> $PGDATA seems like the right place to put the file, since we can only
> have one active postmaster at a time in a database directory.

Right.

> I assume you'll also create a script that sends SIGTERM or other
> requested signal to the postmaster, using this file?

Of course:-) I'm thinking about to make an apachectl-like script.
--
Tatsuo Ishii


Re: [HACKERS] pid file for postmaster?

From
Tom Lane
Date:
Tatsuo Ishii <t-ishii@sra.co.jp> writes:
>> I assume you'll also create a script that sends SIGTERM or other
>> requested signal to the postmaster, using this file?

> Of course:-) I'm thinking about to make an apachectl-like script.

If you think Apache has a good user interface for a signal-sending
script, then by all means steal their design ;-).  If not that, we
should steal someone else's.  No reason to reinvent this wheel,
nor to make sysadmins learn yet another variant on the theme.
        regards, tom lane


Re: [HACKERS] pid file for postmaster?

From
Tim Holloway
Date:
Red Hat ALREADY creates a file "postmaster.pid" in the /var/lock directory.
I don't know how far the /var/lock convention goes across different platforms,
but I recommend using IT or its equivalent, I still have scars from my OS/2
days where every product put its goodies in a different place and you had to
guess where, how, and in what format.
   Regards,     Tim Holloway

Tatsuo Ishii wrote:
> 
> From: Tom Lane <tgl@sss.pgh.pa.us>
> > Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> > > It would be nice if postmaster has its own pid file to send signals to
> > > it. I think the pid file could be placed under $PGDATA. Opinions?
> >
> > Yes, that's been discussed before, and I think it's even got an entry
> > on the TODO list.  If you've got time to tackle it now, great!
> >
> > $PGDATA seems like the right place to put the file, since we can only
> > have one active postmaster at a time in a database directory.
> 
> Right.
> 
> > I assume you'll also create a script that sends SIGTERM or other
> > requested signal to the postmaster, using this file?
> 
> Of course:-) I'm thinking about to make an apachectl-like script.
> --
> Tatsuo Ishii
> 
> ************


Re: [HACKERS] pid file for postmaster?

From
Tom Lane
Date:
Tim Holloway <mtsinc@southeast.net> writes:
> Red Hat ALREADY creates a file "postmaster.pid" in the /var/lock directory.

If they did it just like that, then they broke the ability to run more
than one postmaster on the same machine.  Also, there is the question
of what the permissions are on /var/lock.  If they're tight then postgres
can't be an ordinary unprivileged user, which is bad.  If they're loose
then anyone can come along and cause trouble by fiddling with the lock
files.

There was considerable discussion of this whole area last year in
pg-hackers (check the thread "flock patch breaks things here" and
related threads starting in late Aug. 1998).  We were focusing mostly
on the use of lockfiles to ensure that one didn't accidentally start
two postmasters in the same database dir and/or with the same port
number; but if the lockfiles contain PIDs then of course they can also
serve as a contact point for a signal-sender.

Tatsuo, if you have forgotten that discussion you may want to go back
and re-read it.
        regards, tom lane


Re: [HACKERS] pid file for postmaster?

From
Tim Holloway
Date:
You are quite correct. They assume that there will be one and only one
postmaster, which may be started or stopped at runlevel switch or
manually via /etc/rc.d/init.d/postmaster stop|start|restart

Similar systems have made PIDfiles like:

/var/run/postgres/5432

Which would get around the single-postmaster limitation and allow you to
make postgres own the PID directory. Whether this has traversal-rights
issues or not, I don't know. Red Hat control starts the postmaster as an
'su' process from root, and they may do the WRITING of the PIDfile from
that account.

Tom Lane wrote:
> 
> Tim Holloway <mtsinc@southeast.net> writes:
> > Red Hat ALREADY creates a file "postmaster.pid" in the /var/lock directory.
> 
> If they did it just like that, then they broke the ability to run more
> than one postmaster on the same machine.  Also, there is the question
> of what the permissions are on /var/lock.  If they're tight then postgres
> can't be an ordinary unprivileged user, which is bad.  If they're loose
> then anyone can come along and cause trouble by fiddling with the lock
> files.
> 
> There was considerable discussion of this whole area last year in
> pg-hackers (check the thread "flock patch breaks things here" and
> related threads starting in late Aug. 1998).  We were focusing mostly
> on the use of lockfiles to ensure that one didn't accidentally start
> two postmasters in the same database dir and/or with the same port
> number; but if the lockfiles contain PIDs then of course they can also
> serve as a contact point for a signal-sender.
> 
> Tatsuo, if you have forgotten that discussion you may want to go back
> and re-read it.
> 
>                         regards, tom lane


Re: [HACKERS] pid file for postmaster?

From
Michael Meskes
Date:
On Wed, Nov 24, 1999 at 01:33:37AM -0500, Tom Lane wrote:
> > it. I think the pid file could be placed under $PGDATA. Opinions?
> ... 
> $PGDATA seems like the right place to put the file, since we can only
> have one active postmaster at a time in a database directory.

Ehem, I think the correct place would be /var/run. At least that's what the
filesystem standard says IIRC.

Michael
-- 
Michael Meskes                         | Go SF 49ers!
Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
Email: Michael@Fam-Meskes.De           | Use PostgreSQL!


Re: [HACKERS] pid file for postmaster?

From
Bruce Momjian
Date:
> Red Hat ALREADY creates a file "postmaster.pid" in the /var/lock directory.
> I don't know how far the /var/lock convention goes across different platforms,
> but I recommend using IT or its equivalent, I still have scars from my OS/2
> days where every product put its goodies in a different place and you had to
> guess where, how, and in what format.

Problem with that it is going to require root permission to create that
file or directory if it doesn't exist.  I think we have to put it in the
pgsql/data directory.  Sorry.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] pid file for postmaster?

From
Hannu Krosing
Date:
Michael Meskes wrote:
> 
> On Wed, Nov 24, 1999 at 01:33:37AM -0500, Tom Lane wrote:
> > > it. I think the pid file could be placed under $PGDATA. Opinions?
> > ...
> > $PGDATA seems like the right place to put the file, since we can only
> > have one active postmaster at a time in a database directory.
> 
> Ehem, I think the correct place would be /var/run. At least that's what the
> filesystem standard says IIRC.

But that forces us to distinguish between several running backends, with the 
main aim of _not_ allowing two distinct backends to be run from the same 
$PGDATA.

we could of course start naming them like /var/run/pgsql.pid.for.var.lib.pgsql

------------
Hannu


Re: [HACKERS] pid file for postmaster?

From
Dmitry Samersoff
Date:
On 25-Nov-99 Michael Meskes wrote:
> On Wed, Nov 24, 1999 at 01:33:37AM -0500, Tom Lane wrote:
>> > it. I think the pid file could be placed under $PGDATA. Opinions?
>> ... 
>> $PGDATA seems like the right place to put the file, since we can only
>> have one active postmaster at a time in a database directory.
> 
> Ehem, I think the correct place would be /var/run. At least that's what the
> filesystem standard says IIRC.

I agree ...



---
Dmitry Samersoff, dms@wplus.net, ICQ:3161705
http://devnull.wplus.net
* There will come soft rains ...


Re: [HACKERS] pid file for postmaster?

From
Tim Holloway
Date:
Just playing Devil's Advocate.

Having to have root persmission to set up a system is more the rule than the exception,
though. Under Windows NT, for example, you can't create the registry keys except as
an administrator, even though unprivileged users will be setting the values.
Considering what having major DBMS installed could do to the system load, one could
even argue that ONLY an administrator should be allowed to install it!

But that's another issue entirely.....

Bruce Momjian wrote:
> 
> > Red Hat ALREADY creates a file "postmaster.pid" in the /var/lock directory.
> > I don't know how far the /var/lock convention goes across different platforms,
> > but I recommend using IT or its equivalent, I still have scars from my OS/2
> > days where every product put its goodies in a different place and you had to
> > guess where, how, and in what format.
> 
> Problem with that it is going to require root permission to create that
> file or directory if it doesn't exist.  I think we have to put it in the
> pgsql/data directory.  Sorry.
> 
> --
>   Bruce Momjian                        |  http://www.op.net/~candle
>   maillist@candle.pha.pa.us            |  (610) 853-3000
>   +  If your life is a hard drive,     |  830 Blythe Avenue
>   +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026


Re: [HACKERS] pid file for postmaster?

From
Bruce Momjian
Date:
[Charset KOI8-R unsupported, filtering to ASCII...]
> 
> On 25-Nov-99 Michael Meskes wrote:
> > On Wed, Nov 24, 1999 at 01:33:37AM -0500, Tom Lane wrote:
> >> > it. I think the pid file could be placed under $PGDATA. Opinions?
> >> ... 
> >> $PGDATA seems like the right place to put the file, since we can only
> >> have one active postmaster at a time in a database directory.
> > 
> > Ehem, I think the correct place would be /var/run. At least that's what the
> > filesystem standard says IIRC.
> 
> I agree ...
> 

I think the idea was to put the file in /data, and symlink to /tmp or
/var/run.

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] pid file for postmaster?

From
Michael Meskes
Date:
On Thu, Nov 25, 1999 at 09:38:09PM +0200, Hannu Krosing wrote:
> But that forces us to distinguish between several running backends, with the 
> main aim of _not_ allowing two distinct backends to be run from the same 
> $PGDATA.

Oops. It seems I did not completely read that mail.

> we could of course start naming them like /var/run/pgsql.pid.for.var.lib.pgsql

Does not make sense IMO.

Michael
-- 
Michael Meskes                         | Go SF 49ers!
Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
Email: Michael@Fam-Meskes.De           | Use PostgreSQL!