need to delete postmaster.pid file. automate it? - Mailing list pgsql-admin

From mlaks
Subject need to delete postmaster.pid file. automate it?
Date
Msg-id 200305052327.45943.mlaks@bellatlantic.net
Whole thread Raw
Responses Re: need to delete postmaster.pid file. automate it?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-admin
Hii!
I am using Postgresql 7.2.1 on Redhat Linux 7.3  as the database that supports
another application. At bootup, the other application checks whether or not
Postgresql is running and if Postgresql is not running, it fails.

The system has been quite stable and has run for almost nonstop for many
months.

However, ocassionally something goes wrong and the application fails because
Postgresql goes down. I believe it is usually when the there is a power surge
in the Hospital where these machines reside. This application failure seems
to be due to an improper shutdown of Postgresql. Sometimes when the  database
backed application fails it can be restarted by simply rebooting the machine.
Postgresql gets restarted and then the application can get started during
normal bootup.

However, sometimes Postgresql won't start. When I intervene manually, and
attempt to run pg_ctl stop,  I get an error that there is not any postgresql
process, and then when I run pg_ctl start, the message says something about
memory being reserved (I don't really remember the exact message- but
whatever - Postgresql  nicely tells me to proceed to delete the file
/var/lib/pgsql/data/ostmaster.pid.
I do that and then all is fine. I can then restart Postgresql with pg_ctl
start and then the application needing Postgresql starts nicely.

I would like to automate this process of deleting postmaster.pid if postgresql
is not running and would like to ask my question
.
What risk is there in automating the process (say via perl or shell script).
Also advice on how to do it.

So I would start my application, if that fails, check if postgresql is running
(? perhaps with ps -aux|grep postgresql ) then restart postgresql, check for
an error, and if that fails, delete postmaster.pid and restart pg_ctl start,
and then start up the database backed application.

Are there any pitfalls that I am not aware of?

Thank you,

Mitchell Laks


pgsql-admin by date:

Previous
From: "Sidar Lopez Cruz"
Date:
Subject: News in 7.4
Next
From: Tom Lane
Date:
Subject: Re: need to delete postmaster.pid file. automate it?