Ruslan A Dautkhanov <[EMAIL PROTECTED]> writes: > Server rebooted occasionally after power failure. > And I have stale postmaster.pid file, so postmaster didn't start with error > bill postgres[600]: [1-1] FATAL: file "postmaster.pid" already exists
You probably need a newer postgres version (you didn't say what you are using) and/or a more carefully written start script. Your proposed change in the start script is useless --- do you think the postmaster doesn't check that already? Furthermore, it's actually dangerous for reasons we need not get into here; suffice to say that automated removal of that lock file is NOT a good idea. The problem comes up when the startup timing is just different enough that the PID belonging to the postmaster in the previous boot cycle now belongs to the shell that's launching it. The postmaster sees a live process of the correct userid (ie, postgres) and has to assume that that's a pre-existing postmaster. We've fixed this in recent releases by having the postmaster also check for a match to its parent process ID (getppid). The care in the start script comes because this only works for one level up. Therefore, you can't "su -c pg_ctl start ..." because that would create three levels of postgres-owned processes (shell, pg_ctl, postmaster) and if the PID count is off by 2 instead of 1 then we still lose. You have to invoke the postmaster directly, "su -c postmaster ...". (Hm, actually it might work to do "su -c 'exec pg_ctl ...'" ... I have not tried that.) regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly