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 20:11:35
Message-ID: 27405.1175544695@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM> writes:
> 1) Is there still some reason have negative value in postmaster.pid?

Just to distinguish postmasters from standalone backends in the error
messages. I think that's still useful.

> 2) Why 100? What race condition should happen? This piece of code looks
> like kind of magic.

There are at least two race cases identified in the comments in the
loop.

> 3) Why pid checking and cleanup is in postgres? I think it is role of
> pg_ctl or init scripts.

Let's see, instead of one place in the postgres code we should do it in
N places in different init scripts, and just trust to luck that a
particular installation is using an init script that knows to do that?
I don't think so. Besides, how is the init script going to remove it
again? It won't still be running when the postmaster exits.

> 4) The following condition is buggy, because atoi function does not have
> defined result if parameter is not valid number.

> if (other_pid <= 0)

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 don't think I've yet seen any reports that suggest that more syntax
checking of the lock file would be a useful activity.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2007-04-02 20:33:25 Bonjour patch
Previous Message David Fetter 2007-04-02 20:10:05 Re: [HACKERS] Arrays of Complex Types