No Logs or History are available anymore

Hi all,
I am facing a Problem with my HA. Since some weeks it is not possible for me to see any Logs of the Devices or any Historical Data.
On my Dashboards the Graphics just keep loading:

I am don’t have any idear to troubleshoot this Problem.

Here are my current HA Versions:

  • Core2024.10.4
  • Supervisor2024.10.3
  • Operating System13.2
  • Frontend20241002.4

Check Settings → System → Logs for database/recorder errors.

I found the following errors:

1:

Logger: homeassistant.components.recorder.core
Quelle: components/recorder/core.py:686
Integration: Recorder (Dokumentation, Probleme)
Erstmals aufgetreten: 29. Oktober 2024 um 10:09:50 (1 Vorkommnisse)
Zuletzt protokolliert: 29. Oktober 2024 um 10:09:50

Recorder._run threw unexpected exception, recorder shutting down
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/cursor.py", line 1136, in fetchall
    rows = dbapi_cursor.fetchall()
           ^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.DatabaseError: database disk image is malformed

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 686, in run
    self._run()
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 791, in _run
    self._run_event_loop()
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 835, in _run_event_loop
    self._pre_process_startup_events(startup_task_or_events)
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 868, in _pre_process_startup_events
    self.event_data_manager.load(non_state_change_events, session)
  File "/usr/src/homeassistant/homeassistant/components/recorder/table_managers/event_data.py", line 57, in load
    self._load_from_hashes(hashes, session)
  File "/usr/src/homeassistant/homeassistant/components/recorder/table_managers/event_data.py", line 99, in _load_from_hashes
    for data_id, shared_data in execute_stmt_lambda_element(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/util.py", line 199, in execute_stmt_lambda_element
    return executed.all()
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 1379, in all
    return self._allrows()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/result.py", line 548, in _allrows
    rows = self._fetchall_impl()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/cursor.py", line 2135, in _fetchall_impl
    return self.cursor_strategy.fetchall(self, self.cursor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/cursor.py", line 1140, in fetchall
    self.handle_exception(result, dbapi_cursor, e)
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/cursor.py", line 1081, in handle_exception
    result.connection._handle_dbapi_exception(
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2353, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/cursor.py", line 1136, in fetchall
    rows = dbapi_cursor.fetchall()
           ^^^^^^^^^^^^^^^^^^^^^^^
sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) database disk image is malformed
(Background on this error at: https://sqlalche.me/e/20/4xp6)

2:

Logger: homeassistant.components.recorder.util
Quelle: components/recorder/util.py:202
Integration: Recorder (Dokumentation, Probleme)
Erstmals aufgetreten: 29. Oktober 2024 um 10:09:49 (3 Vorkommnisse)
Zuletzt protokolliert: 29. Oktober 2024 um 10:09:50

Error executing query: (sqlite3.DatabaseError) database disk image is malformed (Background on this error at: https://sqlalche.me/e/20/4xp6)

Yep. Your database is corrupt. You have two options.

  1. Delete config/home-assistant_v2.db and restart to recreate the database. YOU WILL LOOSE ALL YOUR HISTORY, but none of your configuration. Or

  2. Search the forum for database repair topics. Others have had success with this.

Hi Christian, welcome to the forum!

Are you running your HA on a RPi with SD card?

Do you know why this happen or how often?
At the End it is really bad to loose all your History Data.

Asking this because I don’t like to do this again after the next Update.

Yes, I use a Respberry Pi 4 with an SD card.

Using an SD card is one reason it can happen.