ddev

My ddev project says "db service stopped" and I can't get it started "db service health check timed out"


I was happily working away on a ddev project and I brought it up today and it says "db service stopped" and it doesn't seem to be fixable. ddev also said "db service health check timed out"

db service stopped


Solution

  • Edit 2024-06-27:

    I don't think this is a problem any more, but in any case, doing a ddev poweroff before shutting down your computer or your Docker provider is a good practice. That stops all DDEV projects and the various docker containers cleanly.

    Original post (probably obsolete): The MariaDB server in the database container doesn't get a chance to clean up, and nontrivial databases are left broken for the next startup (it doesn't seem to harm tiny databases). So if you're upgrading docker, shutting down your host computer, or just exiting docker, you'd be wise to first do a ddev stop or a ddev remove. (Note that a simple ddev remove does not throw away your db, it will be there for you when you start again.)

    Also note that in releases before ddev v0.17.0, the ddev remove command itself had this problem: It could corrupt the db by not allowing enough time for the db container to clean up before destroying it.

    I don't think this affects Linux users, and am not sure about Windows.

    TLDR;

    If your MariaDB/MySQL database is corrupted, you may be able to recover by adding a file named .ddev/mysql/recovery.cnf to your project and ddev start:

    [mysqld]
    innodb_force_recovery = 1
    

    After recovery, remove the the file .ddev/mysql/recovery.cnf Your database is not guaranteed to be undamaged, even if it comes up OK.