Skip site navigation (1) Skip section navigation (2)

Re: Questions about pid file creation code

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Questions about pid file creation code
Date: 2007-04-02 21:42:14
Message-ID: 29035.1175550134@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM> writes:
> Tom Lane wrote:
>> Just to distinguish postmasters from standalone backends in the error
>> messages.  I think that's still useful.

> I'm not sure what you mean. It is used only in CreatePidFile function 
> and I think that if directory is locked by some process, I don't see any 
> useful reason to know if it is postmaster or standalone backend.

You don't?  Consider the decisions the user needs to take upon seeing
the message --- should he kill that other process or not, and if so how?
Knowing whether it's a postmaster seems pretty important to me.

> Yes there are. But it does not sense for me. If I want to open file and 
> another process remove it, why I want to try created it again when 
> another process going to do it?

That could be the track of another postmaster just now shutting down.
There's no reason to fail to start in such a scenario.  The looping
logic is necessary anyway (to guard against races involving two
postmasters trying to start at the same time), so we might as well let
it handle this case too.

> I'm sorry, I meant why there is a pid cleanup which stays there after 
> another postmaster crash. Many application only check OK there is some 
> pid file -> exit. And rest is on start script or some other monitoring 
> facility.

The start script does not typically have the intelligence to get this
right, particularly not the is-shmem-still-in-use part.  If you check
the archives you will find many of us on record telling people who think
they should remove the pidfile in their start script that they're crazy.

>> It's not actually trying to validate the syntax of the lock file, only
>> to make certain it doesn't trigger any unexpected behavior in kill().

> I not sure if we talk about same place.

Yes, we are.  Read the kill(2) man page and note the special behaviors
for pid = 0 or -1.  The test is just trying to be darn certain we don't
invoke those behaviors.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Mark DilgerDate: 2007-04-02 22:02:21
Subject: Re: Bug in UTF8-Validation Code?
Previous:From: Bruce MomjianDate: 2007-04-02 21:36:12
Subject: Re: So are we calling it: Feature Freeze?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group