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

Questions about pid file creation code

From: Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Questions about pid file creation code
Date: 2007-04-02 18:55:11
Message-ID: 4611518F.8010508@sun.com (view raw or flat)
Thread:
Lists: pgsql-hackers
I'm looking on pid file creation code (src/backend/utils/init/miscinit.c 
  - CreateLockFile) and I have couple of questions:

1) Is there still some reason have negative value in postmaster.pid? It 
happens only if backend runs in single mode. But I think now is not 
necessary to use it. And there are some confusing messages about 
postgres/postmaster. See:

errhint("Is another postgres (PID %d) running in data directory \"%s\"?",
(int) other_pid, refName) :
errhint("Is another postmaster (PID %d) running in data directory \"%s\"?",
(int) other_pid, refName)) :

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

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


4) The following condition is buggy, because atoi function does not have 
defined result if parameter is not valid number. (OK in most 
implementation it really returns 0)

  if (other_pid <= 0)
              elog(FATAL, "bogus data in lock file \"%s\": \"%s\"",
                   filename, buffer)

I think usage of strtol there should be better.


		Zdenek

Responses

pgsql-hackers by date

Next:From: Heikki LinnakangasDate: 2007-04-02 19:00:03
Subject: CheckpointStartLock starvation
Previous:From: Hiroki KataokaDate: 2007-04-02 18:28:58
Subject: Re: Proposal: Adding JIS X 0213 support

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