Questions about pid file creation code - Mailing list pgsql-hackers

From Zdenek Kotala
Subject Questions about pid file creation code
Date
Msg-id 4611518F.8010508@sun.com
Whole thread Raw
Responses Re: Questions about pid file creation code  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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


pgsql-hackers by date:

Previous
From: "Simon Riggs"
Date:
Subject: Re: One-time plans
Next
From: Heikki Linnakangas
Date:
Subject: CheckpointStartLock starvation