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

Related posts:

  1. Note to self re: postgis
  2. Build your own routing solution
  3. How to not setup an online imagery shop
  4. When PDA’s fight back
  5. 10 utils to make opensource gis that little bit easier

10 Responses to “PostgreSQL driving you nuts?”


  1. Gravatar Icon 1 Mateusz Loskot

    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. Gravatar Icon 2 Chris Tweedie

    Did my suggestions work for you Mateusz? Good to know its not just me!

  3. Gravatar Icon 3 Iwo

    Thanks man! You saved my ass. I owe you a beer!

  4. Gravatar Icon 4 Mateusz Loskot

    Chris, I haven’t actually checked your suggestion. I’ll do it tomorrow and report back.

  5. Gravatar Icon 5 Chris Tweedie

    Hey Iwo, beer is always welcome :-)

  6. Gravatar Icon 6 Mateusz Loskot

    Chris, I tried your trick and it’s been working for me for a day, however the logs still show the “reattach to shared memory” message from time to time.

  7. Gravatar Icon 7 Mateusz Loskot

    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.

  8. Gravatar Icon 8 Chris Tweedie

    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

  9. Gravatar Icon 9 Mateusz Loskot

    Yes, I remove correct files. Anyway, I boot my computer, I start PostgreSQL manually, and it works this way, more or less :-)
    Thanks!

  1. 1 GIS-Lab Blog» Архив блога » Новости вокруг
Comments are currently closed.