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.


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?


Reply via email to