On Tue, May 23, 2006 at 05:23:16PM +0200, Andreas Joseph Krogh wrote: > Hi all. > > I've experienced several times that PG has died somehow and the > postmaster.pid > file still exists 'cause PG hasn't had the ability to delete it upon proper > shutdown. Upon start-up, after such an incidence, PG tells me another PG is > running and that I either have to shut down the other instance, or delete the > postmaster.pid file if there really isn't an instance running. This seems > totally unnecessary to me. Why doesn't PG use file-locking to tell if another > PG is running or not? If PG holds an exclusive-lock on the pid-file and the > process crashes, or shuts down, then the lock(which is process-based and > controlled by the kernel) will be removed and another PG which tries to start > up can detect that. Using the existence of the pid-file as the only evidence > gives too many false positives IMO.
Well, maybe you could tweak postgres startup script, add check for post master (either 'pgrep postmaster' or 'ps -axu | grep [p]ostmaster'), and delete pid file on negative results. i.e. #!/bin/bash PID=`pgrep -f /usr/bin/postmaster`; if [[ $PID ]]; then echo "'$PID'"; # postgres is already running else echo "Postmaster is not running"; # delete stale PID file fi
pgpBL3yb1NFGM.pgp
Description: PGP signature