I am writing a docker-compose config with a container with PostgreSQL in it. docker-compose has a configuration options called restart. If I enable it then whenever the Postgres process stops it will restart Postgres rightaway. However it is (probably) not relevant how it is restarted.

I know that in MySQL it is not safe to start the database right after it stopped because MyISAM tables may be broken. One has to manually repair MyISAM tables first with an unrelated command-line tool and then start the db.

So I wonder if it is generally safe to just restart PostgreSQL in case something is wrong. Or maybe we should first backup, repair, read logs and only then try to start it back.

A related situation would be a power outage for instance. What do I do after that?

1 Answer 1


Postgres generally handles server restarts pretty well. Assuming that all the correct hardware is in place (battery-backed cache, etc.), bringing up Postgres after a crash will automatically cause it to enter recovery mode, where it will attempt to replay all the WAL files since the last CHECKPOINT. Once it has finish replaying up to a consistent state, you are free to use the database and continue with your business. Having said that, however, it's up to you as the DBA to perform consistency checks as per your business requirements to ensure there is no corruption.

Disclosure: I work for EnterpriseDB (EDB) as a Support Engineer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.