Occasionally in our lab, our postgres 8.3 database will get orphaned from the pid file, and we get this message when trying to shut down the database:
Error: pid file is invalid, please manually kill the stale server process postgres
When this happens, we immediately do a pg_dump
so we can restore the database later. But, if we just kill -9 the orphan postgres
process and then start it, the database starts only with the data from the last successful shutdown. But if you psql
to it before killing it, the data is all available, thus why the pg_dump
works.
Is there a way to gracefully shutdown the orphaned postgres process so we don't have to go through the pg_dump and restore? Or is there a way to have the database recover after killing the orphaned process?