core: recorder database migration failed after core update from 2023.3.x to 2023.5.2 with UNIQUE constraint failed
The problem
After upgrading from HA core 2023.3.x (i think 5 or 6) to 2023.5.2 I got a corrupt database. The complete history is gone. See tracebacks in log below.
The database is rather big due to the long purge time.
Any chance to restore the database, at least historical data? If yes, how?
What version of Home Assistant Core has the issue?
core-2023.5.2
What was the last working version of Home Assistant Core?
core-2023.3.x
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Recorder
Link to integration documentation on our website
https://www.home-assistant.io/integrations/recorder
Diagnostics information
No response
Example YAML snippet
recorder:
purge_keep_days: 120
Anything in the logs that might be useful for us?
2023-05-05 23:16:03.644 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key "sensor". Check lines 11 and 85
2023-05-05 23:16:03.886 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration roborock which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:16:03.889 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration openmediavault which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:16:03.892 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration pegelonline which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:16:03.896 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:16:03.899 WARNING (SyncWorker_2) [homeassistant.loader] We found a custom integration philips_airpurifier_coap which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:16:51.456 ERROR (SyncWorker_4) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd080453d60>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:16:57.393 WARNING (MainThread) [homeassistant.config_entries] Config entry 'FRITZ!Box 7490 (UI)' for fritz integration not ready yet: Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd080453d60>: Failed to establish a new connection: [Errno 113] Host is unreachable')); Retrying in background
2023-05-05 23:16:57.508 WARNING (SyncWorker_4) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key "sensor". Check lines 11 and 85
2023-05-05 23:16:59.119 WARNING (MainThread) [homeassistant.components.generic.camera] Loading generic IP camera via configuration.yaml is deprecated, it will be automatically imported. Once you have confirmed correct operation, please remove 'generic' (IP camera) section(s) from configuration.yaml
2023-05-05 23:17:10.268 WARNING (Recorder) [homeassistant.components.recorder.migration] Database is about to upgrade from schema version: 35 to: 41
2023-05-05 23:17:10.353 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding columns context_id_bin, context_user_id_bin, context_parent_id_bin to table states. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:17:10.413 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding columns context_id_bin, context_user_id_bin, context_parent_id_bin to table events. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:17:10.469 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding index `ix_events_context_id_bin` to table `events`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:17:10.669 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding index `ix_states_context_id_bin` to table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:17:13.331 ERROR (SyncWorker_4) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd07b09e410>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:17:26.706 ERROR (SyncWorker_3) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd0751317b0>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:17:50.166 ERROR (SyncWorker_10) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd075131540>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:17:55.306 WARNING (MainThread) [custom_components.philips_airpurifier_coap.config_flow] Failed to connect: [Errno 111] received through errqueue
2023-05-05 23:17:55.314 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
ConnectionRefusedError: [Errno 111] received through errqueue
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/config/custom_components/philips_airpurifier_coap/config_flow.py", line 77, in async_step_dhcp
client = await CoAPClient.create(self._host)
File "/usr/local/lib/python3.10/site-packages/aioairctrl/coap/client.py", line 38, in create
await obj._init()
File "/usr/local/lib/python3.10/site-packages/aioairctrl/coap/client.py", line 33, in _init
await self._sync()
File "/usr/local/lib/python3.10/site-packages/aioairctrl/coap/client.py", line 54, in _sync
response = await self._client_context.request(request).response
File "/usr/local/lib/python3.10/site-packages/aiocoap/protocol.py", line 606, in _run_outer
await cls._run(app_request, response, weak_observation, protocol, log)
File "/usr/local/lib/python3.10/site-packages/aiocoap/protocol.py", line 665, in _run
blockresponse = await blockrequest.response
aiocoap.error.NetworkError: [Errno 111] received through errqueue
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/discovery_flow.py", line 95, in _async_start
await gather_with_concurrency(
File "/usr/src/homeassistant/homeassistant/util/async_.py", line 178, in gather_with_concurrency
return await gather(
File "/usr/src/homeassistant/homeassistant/util/async_.py", line 176, in sem_task
return await task
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 845, in async_init
flow, result = await task
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 873, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/config/custom_components/philips_airpurifier_coap/config_flow.py", line 101, in async_step_dhcp
raise exceptions.ConfigEntryNotReady from ex
homeassistant.exceptions.ConfigEntryNotReady: [Errno 111] received through errqueue
2023-05-05 23:18:25.199 WARNING (MainThread) [custom_components.philips_airpurifier_coap.config_flow] Timeout, host 192.168.179.3 looks like a Philips AirPurifier but doesn't answer, aborting
2023-05-05 23:18:33.363 ERROR (SyncWorker_3) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd07b09c7f0>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:19:56.482 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'temperature' when rendering '{{ value_json.temperature }}'
2023-05-05 23:19:56.787 ERROR (SyncWorker_4) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd074e49570>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:21:20.243 ERROR (SyncWorker_9) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd074c05bd0>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:21:29.989 WARNING (Recorder) [homeassistant.components.recorder.migration] Upgrade to version 36 done
2023-05-05 23:21:29.996 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding columns event_type_id to table events. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:21:30.008 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_events_event_type_time_fired_ts` from table `events`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:21:30.196 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding index `ix_events_event_type_id_time_fired_ts` to table `events`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:21:30.543 WARNING (Recorder) [homeassistant.components.recorder.migration] Upgrade to version 37 done
2023-05-05 23:21:30.546 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding columns metadata_id to table states. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:21:30.551 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding index `ix_states_metadata_id_last_updated_ts` to table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:22:43.763 ERROR (SyncWorker_1) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd074aa2020>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:24:07.253 ERROR (SyncWorker_5) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd074ae7d90>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:25:01.340 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'temperature' when rendering '{{ value_json.temperature }}'
2023-05-05 23:25:01.532 WARNING (Recorder) [homeassistant.components.recorder.migration] Upgrade to version 38 done
2023-05-05 23:25:01.538 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_events_event_type_time_fired_ts` from table `events`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.551 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_events_event_type` from table `events`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.562 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_events_event_type_time_fired` from table `events`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.573 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_events_time_fired` from table `events`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.582 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_events_context_user_id` from table `events`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.595 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_events_context_parent_id` from table `events`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.607 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_states_entity_id_last_updated` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.619 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_states_last_updated` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.630 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_states_entity_id` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.640 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_states_context_user_id` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.650 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_states_context_parent_id` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.660 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_states_created_domain` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.669 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_states_entity_id_created` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.677 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `states__state_changes` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.686 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `states__significant_changes` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.696 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_states_entity_id_created` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.704 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_statistics_statistic_id_start` from table `statistics`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.711 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_statistics_short_term_statistic_id_start` from table `statistics_short_term`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.726 WARNING (Recorder) [homeassistant.components.recorder.migration] Upgrade to version 39 done
2023-05-05 23:25:01.729 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_events_event_type_id` from table `events`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.737 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_states_metadata_id` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:01.746 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_statistics_metadata_id` from table `statistics`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:02.139 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_statistics_short_term_metadata_id` from table `statistics_short_term`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:06.056 WARNING (Recorder) [homeassistant.components.recorder.migration] Upgrade to version 40 done
2023-05-05 23:25:06.062 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding index `ix_event_types_event_type` to table `event_types`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:06.070 WARNING (Recorder) [homeassistant.components.recorder.migration] Index ix_event_types_event_type already exists on event_types, continuing
2023-05-05 23:25:06.076 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding index `ix_states_meta_entity_id` to table `states_meta`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:06.083 WARNING (Recorder) [homeassistant.components.recorder.migration] Index ix_states_meta_entity_id already exists on states_meta, continuing
2023-05-05 23:25:06.096 WARNING (Recorder) [homeassistant.components.recorder.migration] Upgrade to version 41 done
2023-05-05 23:25:06.398 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for camera.roborock_s7_maxv_map exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
2023-05-05 23:25:06.542 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for camera.roborock_s7_maxv_map exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
2023-05-05 23:25:07.195 ERROR (Recorder) [homeassistant.components.recorder.util] Error executing query: (sqlite3.IntegrityError) UNIQUE constraint failed: event_types.event_type
[SQL: INSERT INTO event_types (event_type) VALUES (?) RETURNING event_type_id]
[parameters: ('service_registered',)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2108, in _exec_insertmany_context
dialect.do_execute(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 920, in do_execute
cursor.execute(statement, parameters)
sqlite3.IntegrityError: UNIQUE constraint failed: event_types.event_type
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/recorder/util.py", line 130, in session_scope
yield session
File "/usr/src/homeassistant/homeassistant/components/recorder/migration.py", line 1474, in migrate_event_type_ids
session.flush() # Assign ids
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 4153, in flush
self._flush(objects)
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 4289, in _flush
with util.safe_reraise():
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 147, in __exit__
raise exc_value.with_traceback(exc_tb)
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 4250, in _flush
flush_context.execute()
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py", line 467, in execute
rec.execute(self)
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py", line 644, in execute
util.preloaded.orm_persistence.save_obj(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/persistence.py", line 93, in save_obj
_emit_insert_statements(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/persistence.py", line 1133, in _emit_insert_statements
result = connection.execute(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1413, in execute
return meth(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py", line 483, in _execute_on_connection
return connection._execute_clauseelement(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1637, in _execute_clauseelement
ret = self._execute_context(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1836, in _execute_context
return self._exec_insertmany_context(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2116, in _exec_insertmany_context
self._handle_dbapi_exception(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2339, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2108, in _exec_insertmany_context
dialect.do_execute(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 920, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: event_types.event_type
[SQL: INSERT INTO event_types (event_type) VALUES (?) RETURNING event_type_id]
[parameters: ('service_registered',)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
2023-05-05 23:25:07.225 ERROR (Recorder) [homeassistant.components.recorder.core] Unrecoverable sqlite3 database corruption detected: (sqlite3.IntegrityError) UNIQUE constraint failed: event_types.event_type
[SQL: INSERT INTO event_types (event_type) VALUES (?) RETURNING event_type_id]
[parameters: ('service_registered',)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2108, in _exec_insertmany_context
dialect.do_execute(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 920, in do_execute
cursor.execute(statement, parameters)
sqlite3.IntegrityError: UNIQUE constraint failed: event_types.event_type
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 889, in _process_one_task_or_recover
return task.run(self)
File "/usr/src/homeassistant/homeassistant/components/recorder/tasks.py", line 416, in run
if not instance._migrate_event_type_ids(): # pylint: disable=[protected-access]
File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 1238, in _migrate_event_type_ids
return migration.migrate_event_type_ids(self)
File "/usr/src/homeassistant/homeassistant/components/recorder/util.py", line 608, in wrapper
return job(instance, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/recorder/migration.py", line 1474, in migrate_event_type_ids
session.flush() # Assign ids
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 4153, in flush
self._flush(objects)
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 4289, in _flush
with util.safe_reraise():
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/util/langhelpers.py", line 147, in __exit__
raise exc_value.with_traceback(exc_tb)
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 4250, in _flush
flush_context.execute()
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py", line 467, in execute
rec.execute(self)
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py", line 644, in execute
util.preloaded.orm_persistence.save_obj(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/persistence.py", line 93, in save_obj
_emit_insert_statements(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/persistence.py", line 1133, in _emit_insert_statements
result = connection.execute(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1413, in execute
return meth(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py", line 483, in _execute_on_connection
return connection._execute_clauseelement(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1637, in _execute_clauseelement
ret = self._execute_context(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1836, in _execute_context
return self._exec_insertmany_context(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2116, in _exec_insertmany_context
self._handle_dbapi_exception(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2339, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2108, in _exec_insertmany_context
dialect.do_execute(
File "/usr/local/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 920, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: event_types.event_type
[SQL: INSERT INTO event_types (event_type) VALUES (?) RETURNING event_type_id]
[parameters: ('service_registered',)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
2023-05-05 23:25:07.405 ERROR (Recorder) [homeassistant.components.recorder.util] The system will rename the corrupt database file //config/home-assistant_v2.db to //config/home-assistant_v2.db.corrupt.2023-05-05T21:25:07.405478+00:00 in order to allow startup to proceed
2023-05-05 23:25:09.697 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for camera.roborock_s7_maxv_map exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
2023-05-05 23:25:10.810 ERROR (MainThread) [coap] Connection loss was not expected.
2023-05-05 23:25:10.872 ERROR (MainThread) [coap] Connection loss was not expected.
2023-05-05 23:25:11.769 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for camera.roborock_s7_maxv_map exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
2023-05-05 23:25:17.055 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_states_context_id` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:17.065 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_events_context_id` from table `events`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:17.088 WARNING (Recorder) [homeassistant.components.recorder.migration] Dropping index `ix_states_entity_id_last_updated_ts` from table `states`. Note: this can take several minutes on large databases and slow computers. Please be patient!
2023-05-05 23:25:31.475 ERROR (SyncWorker_4) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd089b1e710>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:26:54.867 ERROR (SyncWorker_9) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd073ae5cc0>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:26:57.847 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for camera.roborock_s7_maxv_map exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
2023-05-05 23:28:18.259 ERROR (SyncWorker_5) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd07515c460>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:29:41.811 ERROR (SyncWorker_4) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd074b3b310>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:30:05.674 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'temperature' when rendering '{{ value_json.temperature }}'
2023-05-05 23:30:27.037 WARNING (SyncWorker_5) [homeassistant.loader] We found a custom integration roborock which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:30:27.044 WARNING (SyncWorker_5) [homeassistant.loader] We found a custom integration openmediavault which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:30:27.049 WARNING (SyncWorker_5) [homeassistant.loader] We found a custom integration pegelonline which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:30:27.055 WARNING (SyncWorker_5) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:30:27.060 WARNING (SyncWorker_5) [homeassistant.loader] We found a custom integration philips_airpurifier_coap which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:30:47.362 WARNING (SyncWorker_14) [homeassistant.loader] We found a custom integration roborock which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:30:47.367 WARNING (SyncWorker_14) [homeassistant.loader] We found a custom integration openmediavault which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:30:47.369 WARNING (SyncWorker_14) [homeassistant.loader] We found a custom integration pegelonline which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:30:47.374 WARNING (SyncWorker_14) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:30:47.377 WARNING (SyncWorker_14) [homeassistant.loader] We found a custom integration philips_airpurifier_coap which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-05 23:31:05.043 ERROR (SyncWorker_15) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd0762a0370>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:31:58.026 WARNING (Recorder) [homeassistant.components.recorder.db_schema] State attributes for camera.roborock_s7_maxv_map exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored
2023-05-05 23:32:28.275 ERROR (SyncWorker_10) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd074c53400>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
2023-05-05 23:33:21.354 ERROR (MainThread) [frontend.js.latest.202305033] :0:0 ResizeObserver loop completed with undelivered notifications.
2023-05-05 23:33:51.443 ERROR (SyncWorker_9) [fritzconnection] Unable to get a connection: HTTPConnectionPool(host='192.168.178.31', port=49000): Max retries exceeded with url: /igddesc.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fd0744b5960>: Failed to establish a new connection: [Errno 113] Host is unreachable'))
Additional information
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 42 (20 by maintainers)
Commits related to this issue
- Add additional coverage to event type id migration I have been trying to trigger the issue described in #92650 without luck. I did however generate some more tests to make sure the current code is wo... — committed to home-assistant/core by bdraco a year ago
- Fix race in tracking pending writes in recorder The commit_before flag for jobs did not always work as intended because another session could be opened by another job which would cause the .new flag ... — committed to home-assistant/core by bdraco a year ago
No, they don’t seem to be happening after the upgrade. Many thanks for your help!
Its going to be a bugfix going forward.
Assuming you don’t mind losing any data since you upgraded, If you do a backup, stop HA, and copy the
*corrupt*versions over the live version while HA is stopped it should likely not hit the problem since you need just right order of tasks to make this happen.If it does happen again, you might have to wait for the linked PR to come out in a release