Database trouble after last update

Hello,
I have Ha. working on a nuc with docker
After the latest update I have a lot of trouble because of incompatiblity of docker.
So, I do fiew manipulations and update to the latest version of HA and supervisor.
The system run but all addon waas not fonctionning.
I restore all but not ha.
All addon seams runing well but the in the logs, I have a lot of errors like:

sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) database disk image is malformed

[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)]

[parameters: (‘state_changed’, ‘{}’, ‘LOCAL’, ‘2020-12-17 14:42:10.619437’, ‘2020-12-17 14:42:10.619437’, ‘fdab10afcfa51ade0d5bae34929ffb5e’, None, None)]

(Background on this error at: http://sqlalche.me/e/13/4xp6)

2020-12-17 09:42:14 ERROR (Recorder) [homeassistant.components.recorder] Error executing query: (sqlite3.DatabaseError) database disk image is malformed

[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)]

[parameters: (‘state_changed’, ‘{}’, ‘LOCAL’, ‘2020-12-17 14:42:13.243791’, ‘2020-12-17 14:42:13.243791’, ‘83cb28cd506d4b610261c18e4b314c66’, None, None)]

(Background on this error at: http://sqlalche.me/e/13/4xp6)

2020-12-17 09:42:14 ERROR (Recorder) [homeassistant.components.recorder] Error saving events: (sqlite3.DatabaseError) database disk image is malformed

[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)]

[parameters: (‘state_changed’, ‘{}’, ‘LOCAL’, ‘2020-12-17 14:42:13.243791’, ‘2020-12-17 14:42:13.243791’, ‘83cb28cd506d4b610261c18e4b314c66’, None, None)]

(Background on this error at: http://sqlalche.me/e/13/4xp6)

Traceback (most recent call last):

Please, how can I fix it ??

Many thanks for your help

Looks like database corruption, to delete it do the following:

  1. Stop Home Assistant
  2. Remove home-assistant_v2.db in the config directory
  3. Start Home Assistant
  4. Home Assistant will build a new database
1 Like

thanks for your fast reply.
If I stop h.a how can access to the folder and delete the database ?
Is that a means to “repear” the database ?

Ah didn’t notice that you run Supervised.
I think it will also work when you delete it and then simply restart.
No, this will not repair it, it will delete it and build a fresh one. The history will be lost.

thanks
but if I stop H.A How can I access to the database folder ?

thanks !

You can probably do it through SSHing into the host and locate the volumes mapped to docker, but try deleting it and then restart HA instead of stopping it first.

So glad I stumbled on this thread.

I had the same errors as OP, but from restoring a snapshot to a new Proxmox install.

I used the file editor to delete the database file mentioned above then did a server restart and everything is working well now. Lost all history of course.

1 Like