Upgrade failed due to unclean database shutdown

Hi, yes, exactly this error.

What was happening for me was the following, and I believe the same is true in your case. I was on Scaleway VC1S.

The stop timeout is not enough for this system, after 10 seconds PostgreSQL is still running. Now with -t 10 we are sending a kill signal to PostgreSQL which results in an unclean shutdown case.
This is problem #1.

This means that a db recovery has to run on next startup.

But 5 seconds is not enough for a recovery, so a startup cannot continue. This is problem #2.

Workaround for now:

  1. Do not use ./launcher rebuild, etc. without manually shutting down the instance. Use docker stop app and wait, wait. It will take more than 10 seconds!

  2. Modify the postgresql template and change sleep 5 to sleep 60. This is enough time to have the recovery complete. Your system will work afterwards, but this will leave that file out of sync with the git repo.

Proper fix would be:

  1. Raise the docker stop timeout. I don’t have the host anymore, but could you run time docker stop app and tell us how much it takes for you on a running instance?

  2. Change the postgres template to something dynamic instead of a fixed timeout. I’ve opened this ticket for a proper solution, but will need some help/input to continue: https://github.com/discourse/discourse_docker/issues/309

3 Likes