[solved] After Update: Database error during schema migration

Hi all,

I am running Home Assistant OS in a VM in Proxmox using the MariaDB addon as database for the recorder. I just clicked through some recent updates (OS, Core and MariaDB) and now the history is not working anymore, as database migrations seems to have failed (see log below).

I assume that the following happened: I installed the update for HA Core, and as this was done (at least the UI indicated that it was done) I installed the update for the MariaDB integration, but the HA core update was still in the progress of migrating the database when it was restarting due to its own update.

Is there a way to re-trigger this migration? I tried restoring the (partial) backup that was made prior to the updates, but this does not contain database information, does it?

 Logger: homeassistant.components.recorder.core
Source: components/recorder/migration.py:993
Integration: Recorder (documentation, issues)
First occurred: 6:33:54 AM (1 occurrences)
Last logged: 6:33:54 AM
Database error during schema migration

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.10/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/usr/local/lib/python3.10/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
MySQLdb.OperationalError: (2013, 'Lost connection to MySQL server during query')

Well… I am feeling kinda stupid now… it seems that restarting HA re-triggered this migration. After restart I received a notification that a DB upgrade is in progress which might reduce performance. This notififcation is gone now and history is back again. So I guess, it worked. Sorry for this useless post.

1 Like