Upgraded to 2022.4.1 and notification says database migration failed. I do not understand how to repair it.
log
Logger: homeassistant.components.recorder
Source: components/recorder/migration.py:110
Integration: Recorder (documentation, issues)
First occurred: 7:58:22 AM (1 occurrences)
Last logged: 7:58:22 AM
Database error during schema migration
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1808, in _execute_context
self.dialect.do_execute(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 254, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1034, "Index for table 'states' is corrupt; try to repair it")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 992, in _migrate_schema_and_setup_run
migration.migrate_schema(self, current_version)
File "/usr/src/homeassistant/homeassistant/components/recorder/migration.py", line 79, in migrate_schema
_apply_update(instance, new_version, current_version)
File "/usr/src/homeassistant/homeassistant/components/recorder/migration.py", line 648, in _apply_update
_create_index(instance, "states", "ix_states_attributes_id")
File "/usr/src/homeassistant/homeassistant/components/recorder/migration.py", line 112, in _create_index
raise_if_exception_missing_str(err, ["already exists", "duplicate"])
File "/usr/src/homeassistant/homeassistant/components/recorder/migration.py", line 44, in raise_if_exception_missing_str
raise ex
File "/usr/src/homeassistant/homeassistant/components/recorder/migration.py", line 110, in _create_index
index.create(connection)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/schema.py", line 4287, in create
bind._run_ddl_visitor(ddl.SchemaGenerator, self, checkfirst=checkfirst)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2119, in _run_ddl_visitor
visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/visitors.py", line 524, in traverse_single
return meth(obj, **kw)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 936, in visit_index
self.connection.execute(CreateIndex(index))
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1295, in execute
return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection
return connection._execute_ddl(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1387, in _execute_ddl
ret = self._execute_context(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1851, in _execute_context
self._handle_dbapi_exception(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2032, in _handle_dbapi_exception
util.raise_(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
raise exception
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1808, in _execute_context
self.dialect.do_execute(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 732, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/usr/local/lib/python3.9/site-packages/MySQLdb/connections.py", line 254, in query
_mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1034, "Index for table 'states' is corrupt; try to repair it")
[SQL: CREATE INDEX ix_states_attributes_id ON states (attributes_id)]
(Background on this error at: https://sqlalche.me/e/14/e3q8)
Logger: homeassistant.components.recorder.util
Source: components/recorder/util.py:90
Integration: Recorder (documentation, issues)
First occurred: 7:58:22 AM (1 occurrences)
Last logged: 7:58:22 AM
Error executing query: (MySQLdb._exceptions.OperationalError) (1034, "Index for table 'states' is corrupt; try to repair it") [SQL: CREATE INDEX ix_states_attributes_id ON states (attributes_id)] (Background on this error at: https://sqlalche.me/e/14/e3q8)