I was running a HA 0.50.2 and I upgraded to 0.52 and I had to go through the event database optimization step. I waited and waited for ~40 minutes but there was no visible progress and top reported a CPU core in 100% stuck on a kthread. Although the system was not sluggish, the system load was slowly increasing - it reached 82 in about 1 hour and then the system died and I was disconnected from ssh. Funny thing is - I couldn’t access the ~homeassistant/.homeassistant folder anymore, but other folders worked correctly - so there was something stuck in kernel space.
After a system reboot I get the following errors when starting HA:
Aug 31 13:00:58 bellatrix hass[12779]: INFO:homeassistant.setup:Setting up recorder
Aug 31 13:00:59 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Upgrading recorder db schema to version 4
Aug 31 13:00:59 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_created_domain from table states. Schema Migration will continue; this is not a criti
cal operation.
Aug 31 13:00:59 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__state_changes from table states. Schema Migration will continue; this is not a critical
operation.
Aug 31 13:00:59 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__significant_changes from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:00:59 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_entity_id_created from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:00:59 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Adding index `ix_states_entity_id_last_updated` to database. Note: this can take several minutes on large databases and
slow computers. Please be patient!
Aug 31 13:00:59 bellatrix hass[12779]: ERROR:homeassistant.components.recorder.util:Error executing query: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE INDEX
ix_states_entity_id_last_updated ON states (entity_id, last_updated)']
Aug 31 13:00:59 bellatrix hass[12779]: ERROR:homeassistant.components.recorder:Error during connection setup: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE IN
DEX ix_states_entity_id_last_updated ON states (entity_id, last_updated)'] (retrying in 3 seconds)
Aug 31 13:01:02 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Upgrading recorder db schema to version 4
Aug 31 13:01:02 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_created_domain from table states. Schema Migration will continue; this is not a criti
cal operation.
Aug 31 13:01:02 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__state_changes from table states. Schema Migration will continue; this is not a critical
operation.
Aug 31 13:01:02 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__significant_changes from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:02 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_entity_id_created from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:02 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Adding index `ix_states_entity_id_last_updated` to database. Note: this can take several minutes on large databases and
slow computers. Please be patient!
Aug 31 13:01:02 bellatrix hass[12779]: ERROR:homeassistant.components.recorder.util:Error executing query: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE INDEX
ix_states_entity_id_last_updated ON states (entity_id, last_updated)']
Aug 31 13:01:02 bellatrix hass[12779]: ERROR:homeassistant.components.recorder:Error during connection setup: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE IN
DEX ix_states_entity_id_last_updated ON states (entity_id, last_updated)'] (retrying in 3 seconds)
Aug 31 13:01:05 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Upgrading recorder db schema to version 4
Aug 31 13:01:05 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_created_domain from table states. Schema Migration will continue; this is not a criti
cal operation.
Aug 31 13:01:05 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__state_changes from table states. Schema Migration will continue; this is not a critical
operation.
Aug 31 13:01:05 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__significant_changes from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:05 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_entity_id_created from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:05 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Adding index `ix_states_entity_id_last_updated` to database. Note: this can take several minutes on large databases and
slow computers. Please be patient!
Aug 31 13:01:05 bellatrix hass[12779]: ERROR:homeassistant.components.recorder.util:Error executing query: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE INDEX
ix_states_entity_id_last_updated ON states (entity_id, last_updated)']
Aug 31 13:01:05 bellatrix hass[12779]: ERROR:homeassistant.components.recorder:Error during connection setup: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE IN
DEX ix_states_entity_id_last_updated ON states (entity_id, last_updated)'] (retrying in 3 seconds)
Aug 31 13:01:08 bellatrix hass[12779]: WARNING:homeassistant.setup:Setup of recorder is taking over 10 seconds.
Aug 31 13:01:08 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Upgrading recorder db schema to version 4
Aug 31 13:01:08 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_created_domain from table states. Schema Migration will continue; this is not a criti
cal operation.
Aug 31 13:01:08 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__state_changes from table states. Schema Migration will continue; this is not a critical
operation.
Aug 31 13:01:08 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__significant_changes from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:08 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_entity_id_created from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:08 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Adding index `ix_states_entity_id_last_updated` to database. Note: this can take several minutes on large databases and
slow computers. Please be patient!
Aug 31 13:01:08 bellatrix hass[12779]: ERROR:homeassistant.components.recorder.util:Error executing query: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE INDEX
ix_states_entity_id_last_updated ON states (entity_id, last_updated)']
Aug 31 13:01:08 bellatrix hass[12779]: ERROR:homeassistant.components.recorder:Error during connection setup: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE IN
DEX ix_states_entity_id_last_updated ON states (entity_id, last_updated)'] (retrying in 3 seconds)
Aug 31 13:01:11 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Upgrading recorder db schema to version 4
Aug 31 13:01:11 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_created_domain from table states. Schema Migration will continue; this is not a criti
cal operation.
Aug 31 13:01:11 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__state_changes from table states. Schema Migration will continue; this is not a critical
operation.
Aug 31 13:01:11 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__significant_changes from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:11 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_entity_id_created from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:11 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Adding index `ix_states_entity_id_last_updated` to database. Note: this can take several minutes on large databases and
slow computers. Please be patient!
Aug 31 13:01:11 bellatrix hass[12779]: ERROR:homeassistant.components.recorder.util:Error executing query: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE INDEX
ix_states_entity_id_last_updated ON states (entity_id, last_updated)']
Aug 31 13:01:11 bellatrix hass[12779]: ERROR:homeassistant.components.recorder:Error during connection setup: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE IN
DEX ix_states_entity_id_last_updated ON states (entity_id, last_updated)'] (retrying in 3 seconds)
Aug 31 13:01:14 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Upgrading recorder db schema to version 4
Aug 31 13:01:14 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_created_domain from table states. Schema Migration will continue; this is not a criti
cal operation.
Aug 31 13:01:14 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__state_changes from table states. Schema Migration will continue; this is not a critical
operation.
Aug 31 13:01:14 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__significant_changes from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:14 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_entity_id_created from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:14 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Adding index `ix_states_entity_id_last_updated` to database. Note: this can take several minutes on large databases and
slow computers. Please be patient!
Aug 31 13:01:14 bellatrix hass[12779]: ERROR:homeassistant.components.recorder.util:Error executing query: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE INDEX
ix_states_entity_id_last_updated ON states (entity_id, last_updated)']
Aug 31 13:01:14 bellatrix hass[12779]: ERROR:homeassistant.components.recorder:Error during connection setup: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE IN
DEX ix_states_entity_id_last_updated ON states (entity_id, last_updated)'] (retrying in 3 seconds)
Aug 31 13:01:17 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Upgrading recorder db schema to version 4
Aug 31 13:01:17 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_created_domain from table states. Schema Migration will continue; this is not a criti
cal operation.
Aug 31 13:01:17 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__state_changes from table states. Schema Migration will continue; this is not a critical
operation.
Aug 31 13:01:17 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__significant_changes from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:17 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_entity_id_created from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:17 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Adding index `ix_states_entity_id_last_updated` to database. Note: this can take several minutes on large databases and
slow computers. Please be patient!
Aug 31 13:01:17 bellatrix hass[12779]: ERROR:homeassistant.components.recorder.util:Error executing query: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE INDEX
ix_states_entity_id_last_updated ON states (entity_id, last_updated)']
Aug 31 13:01:17 bellatrix hass[12779]: ERROR:homeassistant.components.recorder:Error during connection setup: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE IN
DEX ix_states_entity_id_last_updated ON states (entity_id, last_updated)'] (retrying in 3 seconds)
Aug 31 13:01:20 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Upgrading recorder db schema to version 4
Aug 31 13:01:20 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_created_domain from table states. Schema Migration will continue; this is not a criti
cal operation.
Aug 31 13:01:20 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__state_changes from table states. Schema Migration will continue; this is not a critical
operation.
Aug 31 13:01:20 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__significant_changes from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:20 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_entity_id_created from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:20 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Adding index `ix_states_entity_id_last_updated` to database. Note: this can take several minutes on large databases and
slow computers. Please be patient!
Aug 31 13:01:20 bellatrix hass[12779]: ERROR:homeassistant.components.recorder.util:Error executing query: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE INDEX
ix_states_entity_id_last_updated ON states (entity_id, last_updated)']
Aug 31 13:01:20 bellatrix hass[12779]: ERROR:homeassistant.components.recorder:Error during connection setup: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE IN
DEX ix_states_entity_id_last_updated ON states (entity_id, last_updated)'] (retrying in 3 seconds)
Aug 31 13:01:24 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Upgrading recorder db schema to version 4
Aug 31 13:01:24 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_created_domain from table states. Schema Migration will continue; this is not a criti
cal operation.
Aug 31 13:01:24 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__state_changes from table states. Schema Migration will continue; this is not a critical
operation.
Aug 31 13:01:24 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__significant_changes from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:24 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_entity_id_created from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:24 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Adding index `ix_states_entity_id_last_updated` to database. Note: this can take several minutes on large databases and
slow computers. Please be patient!
Aug 31 13:01:24 bellatrix hass[12779]: ERROR:homeassistant.components.recorder.util:Error executing query: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE INDEX
ix_states_entity_id_last_updated ON states (entity_id, last_updated)']
Aug 31 13:01:24 bellatrix hass[12779]: ERROR:homeassistant.components.recorder:Error during connection setup: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE IN
DEX ix_states_entity_id_last_updated ON states (entity_id, last_updated)'] (retrying in 3 seconds)
Aug 31 13:01:27 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Upgrading recorder db schema to version 4
Aug 31 13:01:27 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_created_domain from table states. Schema Migration will continue; this is not a criti
cal operation.
Aug 31 13:01:27 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__state_changes from table states. Schema Migration will continue; this is not a critical
operation.
Aug 31 13:01:27 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index states__significant_changes from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:27 bellatrix hass[12779]: WARNING:homeassistant.components.recorder.migration:Failed to drop index ix_states_entity_id_created from table states. Schema Migration will continue; this is not a cr
itical operation.
Aug 31 13:01:27 bellatrix hass[12779]: INFO:homeassistant.components.recorder.migration:Adding index `ix_states_entity_id_last_updated` to database. Note: this can take several minutes on large databases and
slow computers. Please be patient!
Aug 31 13:01:27 bellatrix hass[12779]: ERROR:homeassistant.components.recorder.util:Error executing query: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE INDEX
ix_states_entity_id_last_updated ON states (entity_id, last_updated)']
Aug 31 13:01:27 bellatrix hass[12779]: ERROR:homeassistant.components.recorder:Error during connection setup: (sqlite3.OperationalError) index ix_states_entity_id_last_updated already exists [SQL: 'CREATE IN
DEX ix_states_entity_id_last_updated ON states (entity_id, last_updated)'] (retrying in 3 seconds)
Aug 31 13:01:27 bellatrix hass[12779]: INFO:homeassistant.setup:Setup of domain recorder took 28.9 seconds.
Aug 31 13:01:27 bellatrix hass[12779]: ERROR:homeassistant.setup:Setup failed for recorder: Component failed to initialize.
HA starts, but without history, recorder and logbook components.
Most likely the database is corrupt (I’m guessing it’s home-assistant_v2.db). The file is quite large 995MB on my system.
Is there any procedure I could use to fix it, or should I just rename/delete it and let HA start with a fresh one (and lose history data)?