Upgrade to 0.76.2 failed -

Hi,

I just tried to upgrade my Hassbian instance (RPi3) to 0.76.2. Hass wouldn’t restart for a long time, then finally the UI appeared. Following error showing in the log:

2018-08-25 18:19:58 WARNING (Recorder) [homeassistant.components.recorder.migration] Database requires upgrade. Schema version: 5
2018-08-25 18:20:01 WARNING (Recorder) [homeassistant.components.recorder.migration] Column context_id already exists on events, continueing
2018-08-25 18:20:01 WARNING (Recorder) [homeassistant.components.recorder.migration] Column context_user_id already exists on events, continueing
2018-08-25 18:20:01 ERROR (Recorder) [homeassistant.components.recorder.util] Error executing query: (_mysql_exceptions.OperationalError) (1061, "Duplicate key name 'ix_events_context_id'") [SQL: 'CREATE INDEX ix_events_context_id ON events (context_id)'] (Background on this error at: http://sqlalche.me/e/e3q8)
2018-08-25 18:20:01 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (_mysql_exceptions.OperationalError) (1061, "Duplicate key name 'ix_events_context_id'") [SQL: 'CREATE INDEX ix_events_context_id ON events (context_id)'] (Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds

I see there’s a reference to this problem in the Release Notes, but I have no idea what I’m supposed to do to fix. Can anyone please help me out?

Neil

Go back to a good backup until a new release fixes the problem? :face_with_head_bandage:

Or stop ha, delete the database and start HA. A new db will be created.

Of course, if you still care what time the lights went on three weeks ago, you may not wish to do this.

I ended up just dropping the index and re-upgrading. Everything seems to be working normally, although I still have these warnings in the log:

2018-08-26 12:23:32 WARNING (Recorder) [homeassistant.components.recorder.migration] Database requires upgrade. Schema version: 5
2018-08-26 12:23:33 WARNING (Recorder) [homeassistant.components.recorder.migration] Column context_id already exists on events, continueing
2018-08-26 12:23:33 WARNING (Recorder) [homeassistant.components.recorder.migration] Column context_user_id already exists on events, continueing
2018-08-26 12:23:42 WARNING (MainThread) [homeassistant.setup] Setup of recorder is taking over 10 seconds.

As @nickrout said easiest fix is to delete the database

@Neild1968 One of the most important things to do BEFORE you update is to read about what changes are being implemented along with any breaking changes.


"This release has a migration, initial startup can take ~20 minutes (depends on size DB)

This release includes a database migration to allow us to store context in the database. This will make it possible in the future to introduce attribution. For example, we’ll be able to say which user opened the garage door or which automation triggered the party mode at 3am."

Find the HA database, mine is in .homeassistant, file name home-assistant_v2.db

sqlite3 dbfilename
drop index ix_events_context_id;
.quit;

Restart HA

1 Like