When pg_ctl fails to start postmaster, an event should be logged containing the reason. This information is available on the command line, so it should be possible to use the Windows event log.

Here is what I did:

I installed PostgreSQL 8.0 beta 1 on Windows XP Pro, using the installer from the PGInstaller project.

I didn't run any tests, but was able to run pgadmin, and connect to the template1 database. I left the service running and set to automatically start.

A couple of days later, the service is not running. In programs->administrative tools->service, I right click and select "start service". The following message box is shown: "The PostgreSQL database server 8.0-beta1 service on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alerts service."

There are three events in the event log: "The PostgreSQL Database Server 8.0-beta1 service was successfully sent a start control.", "The PostgreSQL Database Server 8.0-beta1 service entered the running state." and "The PostgreSQL Database Server 8.0-beta1 service entered the stopped state.", all within one second of each other.

I start a cmd window as user postgres ("runas /user:postgres cmd"), and in the new cmd window, run "C:\Program Files\PostgreSQL\8.0-beta1\bin\pg_ctl.exe" start
-D "C:\Program Files\PostgreSQL\8.0-beta1\data\"


The output is:

pg_ctl.exe: Another postmaster may be running. Trying to start postmaster anyway
.
FATAL: lock file "C:/Program Files/PostgreSQL/8.0-beta1/data/postmaster.pid" already exists
HINT: Is another postmaster (PID 1024) running in data directory "C:/Program Files/PostgreSQL/8.0-beta1/data"?
pg_ctl.exe: cannot start postmaster
Examine the log output


So it seems that the database crashed in some way, and left a lockfile, causing a fatal error when the database was next started. This error should end up in the Windows event log.

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
   (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to