Re: file-locking and postmaster.pid

Поиск
Список
Период
Сортировка
От Adis Nezirovic
Тема Re: file-locking and postmaster.pid
Дата
Msg-id 20060523163511.GA12309@hiigarah.team.ba
обсуждение исходный текст
Ответ на file-locking and postmaster.pid  (Andreas Joseph Krogh <andreak@officenet.no>)
Ответы Re: file-locking and postmaster.pid  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
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

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Mark Woodward"
Дата:
Сообщение: Re: Performance Issues
Следующее
От: Tom Lane
Дата:
Сообщение: Re: error-free disabling of individual child partition