SQL ERROR recorder

Suddenly seeing this error repeatedly. Anyone any suggestions?

[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-07-29 14:26:17.481389', '2020-07-29 14:26:17.501686', 'e38e8869559549b1b662643cd4cff225', None, None)]
(Background on this error at: http://sqlalche.me/e/4xp6) (Background on this error at: http://sqlalche.me/e/7s2a)
2020-07-29 15:26:17 ERROR (Recorder) [homeassistant.components.recorder] Error adding event: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (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-07-29 14:26:17.481389', '2020-07-29 14:26:17.501686', 'e38e8869559549b1b662643cd4cff225', None, None)]
(Background on this error at: http://sqlalche.me/e/4xp6) (Background on this error at: http://sqlalche.me/e/7s2a)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 379, in run
    self.event_session.flush()
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2523, in flush
    self._flush(objects)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2619, in _flush
    subtransactions=True
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 953, in begin
    self.transaction = self.transaction._begin(nested=nested)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 317, in _begin
    self._assert_active()
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 296, in _assert_active
    code="7s2a",
sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (sqlite3.DatabaseError) database disk image is malformed

[edit]

Reboot has failed to resolve it.

Any idea how I can get around it or do I need to reinstall?

You could just delete the database file. It only stores states and events.

1 Like