Not sure if I am the only one but after upgrade to 2022.7, I saw two database corruptions. Always restored from backup but very strange instability. Using docker and RPi4, ssd drive, no issues so far…
I log, I had the following:
Log
Logger: homeassistant.components.recorder.util
Source: components/recorder/util.py:95
Integration: Recorder (documentation, issues)
First occurred: 04:13:41 (1 occurrences)
Last logged: 04:13:41
Error executing query: (sqlite3.DatabaseError) database disk image is malformed [SQL: DELETE FROM statistics_short_term WHERE statistics_short_term.id IN
Logger: homeassistant.components.recorder.core
Source: components/recorder/purge.py:546
Integration: Recorder (documentation, issues)
First occurred: 04:13:41 (1 occurrences)
Last logged: 04:13:41
Unrecoverable sqlite3 database corruption detected: (sqlite3.DatabaseError) database disk image is malformed [SQL: DELETE FROM statistics_short_term WHERE statistics_short_term.id IN
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context
self.dialect.do_execute(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
cursor.execute(statement, parameters)
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 610, in _process_one_task_or_recover
return task.run(self)
File "/usr/src/homeassistant/homeassistant/components/recorder/tasks.py", line 73, in run
if purge.purge_old_data(
File "/usr/src/homeassistant/homeassistant/components/recorder/util.py", line 499, in wrapper
return job(instance, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/recorder/purge.py", line 117, in purge_old_data
_purge_short_term_statistics(session, short_term_statistics)
File "/usr/src/homeassistant/homeassistant/components/recorder/purge.py", line 546, in _purge_short_term_statistics
deleted_rows = session.execute(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1712, in execute
result = conn._execute_20(statement, params or {}, execution_options)
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1631, in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/lambdas.py", line 516, in _execute_on_connection
return connection._execute_clauseelement(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1498, in _execute_clauseelement
ret = self._execute_context(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1862, in _execute_context
self._handle_dbapi_exception(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2043, in _handle_dbapi_exception
util.raise_(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
raise exception
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1819, in _execute_context
self.dialect.do_execute(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) database disk image is malformed
[SQL: DELETE FROM statistics_short_term WHERE statistics_short_term.id IN
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/pool/base.py", line 247, in _close_connection
self._dialect.do_close(connection)
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 688, in do_close
dbapi_connection.close()
sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 2744344896 and this is thread id 2988290792.
Logger: homeassistant.components.recorder.util
Source: components/recorder/util.py:299
Integration: Recorder (documentation, issues)
First occurred: 04:13:41 (1 occurrences)
Last logged: 04:13:41
The system will rename the corrupt database file //config/home-assistant_v2.db to //config/home-assistant_v2.db.corrupt.2022-07-14T02:13:41.777249+00:00 in order to allow startup to proceed