PostgreSQL driving you nuts?

I’ve long had issues with PostgreSQL 8.3 and now 8.4 refusing to start on my laptop which is really a pain for live demonstrations of ERDAS Apollo. I’m not sure if anyone else has similar problems, but I believe (or rather have a hunch) that it is something to do with “ungraceful” shutdowns of the db when you may lose power or consistently go to sleep. Its only ever occured on my laptop, so luckily postgres on a server is still stable as hell.

If you are getting something like the following in postgresql.log on Windows or are just tearing your hair out wondering why the service that was working before is no longer starting …

2009-12-04 09:05:37 WSTLOG:  database system is ready to accept connections
FATAL:  could not reattach to shared memory (key=240, addr=02690000): 487
2009-12-04 09:05:38 WSTLOG:  autovacuum launcher started
2009-12-04 09:05:38 WSTLOG:  background writer process (PID 9712) exited with exit code 1
2009-12-04 09:05:38 WSTLOG:  terminating any other active server processes
2009-12-04 09:05:38 WSTLOG:  all server processes terminated; reinitializing
2009-12-04 09:05:48 WSTFATAL:  pre-existing shared memory block is still in use
2009-12-04 09:05:48 WSTHINT:  Check if there are any old server processes still running, and terminate them.

To reliably fix things for me anyway,

  1. Delete postmaster.opts or postmaster.pid (if they exist) in your postgres data dir
  2. Kill the pg_ctl.exe process (if running)
  3. Start the postgres service

Success!

postgres-blog

10 thoughts on “PostgreSQL driving you nuts?”

  1. Chris,

    I use PostgreSQL 8.4 on Windows (Vista x64) I confirm it never auto-starts properly. It was so annoying that I reconfigured the service to start it manually only and I hit “Start Server” option from PostgreSQL menu after every boot. I didn’t try to investigate it, manual startup seems to work quite well, but still sometimes I have try 1-3 times until it starts properly.

  2. Chris, the hack does not help, with time I’m getting more and more the reattach… messages and eventually the server disconnects all connections or goes down, so I have to restart.

  3. Sorry to hear that Mateusz. I cant say mine is behaving like that at all ..

    I made a slight typo in the original post, i said postmaster.opts or postmaster.pid when it should have read “and” not or. Although i doubt this will make any difference for you unfortunately

Comments are closed.