Unanswered: PostgreSQL(pg_ctl) service failed to start but postgres.exe running
I'm new to PostgreSQL. I am facing an intermittent issue in postgreSQL service startup. I'm using postgreSQL 9.2 on windows. Problem is as below
After restarting the computer, sometimes PostgreSQL service is not started automatically. But I see postgres.exe processes running in task manager and postmaster.pid file is created in data directory. But the pg_ctl.exe process is not running. Hence the PostgreSQL service also shows as not started. I have another service which depends on postgreSQL. Even that is not started as postgreSQL service is not started. If I try to restart the service again, it fails saying the server is already running in that data directory
After doing some checks in event viewer, I found 2 error messages. Each message in different instances.
1) Timed out waiting for server startup
2) Lock file "postmaster.pid" already exists. Is another postmaster (PID 3856) running in data directory
Looking at these two error messages, I could think of two possible reasons
1) PostgreSQL service took more time to load all libraries during service startup, causing timeout and terminating pg_ctl.exe process. But postgres.exe processes were already started and not killed, also a postmaster.pid file was created in data directory
2) postgreSQL was not completely unloaded and postmaster.pid was not deleted during machine shutdown
I tried increasing default service startup timeout value to 30 secs, but it didn't help.
workaround is manually killing the existing postgres.exe processes and restarting the service again. But I'm looking for the permanent solution.
Please help me to identify the correct root cause and will be grateful for any suggestion/ solution.