Postgresql on Windows : postmaster.pid remains and prevents restart if the service has crashed

postgresqlwindows-server-2008-r2

I have experienced an annoying problem with Postgresql 9.1.1 x64 running as a Windows service on Windows 2008 R2.

The Postgres service crashed for an unknown reason and it left a postmaster.pid file on disk which prevents the service from restarting.

Is there a way to configure the creation of this file?

Best Answer

This is a safety feature - on Windows the Postgres server uses its PID file as a lock to prevent you from starting more than one postmaster pointing at the same data directory (a quick and easy way to destroy your database).
You should not be looking for ways to bypass this functionality.

If Postgres has actually exited you can remove the PID file and restart it.
You should also be examining your Postgres error logs to find out why the server crashed, and addressing that issue.