Hello,
I’m stuck on a problem with my installation runing latest version (with mariadb addon latest version too). HA is not able to access history, the UI is working, sensors are working, but everything linked to statistic/history looks broken.
Spining for hours where I should see a sensor graph of last 24h.
I know the migration could be long, but I did the upgrade more than 24h ago and my db is < 3 GB.
What I did so far :
- check space on host : ok
- check sd card performance : ok (hdparm + dd)
- check logs : no error with sql nor mariadb
- restart mariadb addon : problem still there
- restart core : problem still there (logical, the addon is not restarted)
- restart host (rpi4 8gb) : ok for a minute or two, then problem occurs.
- connect with an external sql client to mariadb to check processlist : I have some really slow queries running, if I kill them, they come back.
- connect with SSH to host on 22222 and check journalctl everything looks ok (I mean no error with sql, I have errors but not related - with bluetooth)
This is the kind of sql query always running :
WITH anon_1 AS
(SELECT anon_2.context_id_bin AS context_id_bin
FROM (SELECT events.context_id_bin AS context_id_bin
FROM events LEFT OUTER JOIN event_types ON events.event_type_id = event_types.event_type_id LEFT OUTER JOIN event_data ON events.data_id = event_data.data_id
WHERE events.time_fired_ts > 1680643068.831e0 AND events.time_fired_ts < 1681560448.005736e0 AND events.event_type_id IN (SELECT event_types.event_type_id
FROM event_types
WHERE event_types.event_type IN ('logbook_entry', 'automation_triggered', 'script_started')) AND (JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), '$.\"entity_id\"') IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), '$.\"entity_id\"') AS CHAR) IN ('\"binary_sensor.mouvement_buanderie_occupancy\"', '\"binary_sensor.mouvement_cuisine_occupancy\"', '\"binary_sensor.mouvement_garage_occupancy\"', '\"binary_sensor.mouvement_salon_jardin_occupancy\"', '\"binary_sensor.mouvement_salon_rue_occupancy\"', '\"binary_sensor.porte_entree_contact\"', '\"binary_sensor.porte_ext_buanderie_contact\"', '\"binary_sensor.porte_ext_cuisine_contact\"', '\"binary_sensor.porte_garage_ext_contact\"', '\"binary_sensor.porte_salon_jardin_contact\"', '\"binary_sensor.porte_salon_rue_1_contact\"', '\"binary_sensor.porte_salon_rue_2_contact\"', '\"binary_sensor.fenetre_bureau_contact\"', '\"binary_sensor.fenetre_cuisine_contact\"', '\"binary_sensor.fenetre_mathieu_contact\"', '\"binary_sensor.fenetre_parents_jardin_contact\"', '\"binary_sensor.fenetre_parents_rue_1_contact\"', '\"binary_sensor.fenetre_parents_rue_2_contact\"', '\"binary_sensor.fenetre_romane_contact\"', '\"binary_sensor.detecteur_fuite_de_gaz_gas\"', '\"binary_sensor.detecteur_incendie_buanderie_smoke\"', '\"binary_sensor.detecteur_incendie_cuisine_smoke\"', '\"binary_sensor.detecteur_incendie_salon_smoke\"', '\"lock.nuki_porte_entree_lock\"') OR JSON_EXTRACT(CAST(events.event_data AS CHAR), '$.\"entity_id\"') IS NOT NULL AND CAST(JSON_EXTRACT(CAST(events.event_data AS CHAR), '$.\"entity_id\"') AS CHAR) IN ('\"binary_sensor.mouvement_buanderie_occupancy\"', '\"binary_sensor.mouvement_cuisine_occupancy\"', '\"binary_sensor.mouvement_garage_occupancy\"', '\"binary_sensor.mouvement_salon_jardin_occupancy\"', '\"binary_sensor.mouvement_salon_rue_occupancy\"', '\"binary_sensor.porte_entree_contact\"', '\"binary_sensor.porte_ext_buanderie_contact\"', '\"binary_sensor.porte_ext_cuisine_contact\"', '\"binary_sensor.porte_garage_ext_contact\"', '\"binary_sensor.porte_salon_jardin_contact\"', '\"binary_sensor.porte_salon_rue_1_contact\"', '\"binary_sensor.porte_salon_rue_2_contact\"', '\"binary_sensor.fenetre_bureau_contact\"', '\"binary_sensor.fenetre_cuisine_contact\"', '\"binary_sensor.fenetre_mathieu_contact\"', '\"binary_sensor.fenetre_parents_jardin_contact\"', '\"binary_sensor.fenetre_parents_rue_1_contact\"', '\"binary_sensor.fenetre_parents_rue_2_contact\"', '\"binary_sensor.fenetre_romane_contact\"', '\"binary_sensor.detecteur_fuite_de_gaz_gas\"', '\"binary_sensor.detecteur_incendie_buanderie_smoke\"', '\"binary_sensor.detecteur_incendie_cuisine_smoke\"', '\"binary_sensor.detecteur_incendie_salon_smoke\"', '\"lock.nuki_porte_entree_lock\"')) UNION ALL SELECT states.context_id_bin AS context_id_bin
FROM states FORCE INDEX (ix_states_metadata_id_last_updated_ts)
WHERE states.last_updated_ts > 1680643068.831e0 AND states.last_updated_ts < 1681560448.005736e0 AND states.metadata_id IN (5, 393, 373, 381, 382, 371, 365, 370, 372, 396, 383, 384, 3, 366, 380, 367, 368, 375, 374, 83, 389, 385, 376, 209)) AS anon_2 GROUP BY anon_2.context_id_bin)
SELECT events.event_id AS event_id, event_types.event_type AS event_type, events.event_data AS event_data, events.time_fired_ts AS time_fired_ts, events.context_id_bin AS context_id_bin, events.context_user_id_bin AS context_user_id_bin, events.context_parent_id_bin AS context_parent_id_bin, event_data.shared_data AS shared_data, 0 AS state_id, NULL AS state, NULL AS entity_id, NULL AS icon, NULL AS old_format_icon, NULL AS context_only
FROM events LEFT OUTER JOIN event_types ON events.event_type_id = event_types.event_type_id LEFT OUTER JOIN event_data ON events.data_id = event_data.data_id
WHERE events.time_fired_ts > 1680643068.831e0 AND events.time_fired_ts < 1681560448.005736e0 AND events.event_type_id IN (SELECT event_types.event_type_id
FROM event_types
WHERE event_types.event_type IN ('logbook_entry', 'automation_triggered', 'script_started')) AND (JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), '$.\"entity_id\"') IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), '$.\"entity_id\"') AS CHAR) IN ('\"binary_sensor.mouvement_buanderie_occupancy\"', '\"binary_sensor.mouvement_cuisine_occupancy\"', '\"binary_sensor.mouvement_garage_occupancy\"', '\"binary_sensor.mouvement_salon_jardin_occupancy\"', '\"binary_sensor.mouvement_salon_rue_occupancy\"', '\"binary_sensor.porte_entree_contact\"', '\"binary_sensor.porte_ext_buanderie_contact\"', '\"binary_sensor.porte_ext_cuisine_contact\"', '\"binary_sensor.porte_garage_ext_contact\"', '\"binary_sensor.porte_salon_jardin_contact\"', '\"binary_sensor.porte_salon_rue_1_contact\"', '\"binary_sensor.porte_salon_rue_2_contact\"', '\"binary_sensor.fenetre_bureau_contact\"', '\"binary_sensor.fenetre_cuisine_contact\"', '\"binary_sensor.fenetre_mathieu_contact\"', '\"binary_sensor.fenetre_parents_jardin_contact\"', '\"binary_sensor.fenetre_parents_rue_1_contact\"', '\"binary_sensor.fenetre_parents_rue_2_contact\"', '\"binary_sensor.fenetre_romane_contact\"', '\"binary_sensor.detecteur_fuite_de_gaz_gas\"', '\"binary_sensor.detecteur_incendie_buanderie_smoke\"', '\"binary_sensor.detecteur_incendie_cuisine_smoke\"', '\"binary_sensor.detecteur_incendie_salon_smoke\"', '\"lock.nuki_porte_entree_lock\"') OR JSON_EXTRACT(CAST(events.event_data AS CHAR), '$.\"entity_id\"') IS NOT NULL AND CAST(JSON_EXTRACT(CAST(events.event_data AS CHAR), '$.\"entity_id\"') AS CHAR) IN ('\"binary_sensor.mouvement_buanderie_occupancy\"', '\"binary_sensor.mouvement_cuisine_occupancy\"', '\"binary_sensor.mouvement_garage_occupancy\"', '\"binary_sensor.mouvement_salon_jardin_occupancy\"', '\"binary_sensor.mouvement_salon_rue_occupancy\"', '\"binary_sensor.porte_entree_contact\"', '\"binary_sensor.porte_ext_buanderie_contact\"', '\"binary_sensor.porte_ext_cuisine_contact\"', '\"binary_sensor.porte_garage_ext_contact\"', '\"binary_sensor.porte_salon_jardin_contact\"', '\"binary_sensor.porte_salon_rue_1_contact\"', '\"binary_sensor.porte_salon_rue_2_contact\"', '\"binary_sensor.fenetre_bureau_contact\"', '\"binary_sensor.fenetre_cuisine_contact\"', '\"binary_sensor.fenetre_mathieu_contact\"', '\"binary_sensor.fenetre_parents_jardin_contact\"', '\"binary_sensor.fenetre_parents_rue_1_contact\"', '\"binary_sensor.fenetre_parents_rue_2_contact\"', '\"binary_sensor.fenetre_romane_contact\"', '\"binary_sensor.detecteur_fuite_de_gaz_gas\"', '\"binary_sensor.detecteur_incendie_buanderie_smoke\"', '\"binary_sensor.detecteur_incendie_cuisine_smoke\"', '\"binary_sensor.detecteur_incendie_salon_smoke\"', '\"lock.nuki_porte_entree_lock\"')) UNION ALL SELECT NULL AS event_id, NULL AS event_type, NULL AS event_data, states.last_updated_ts AS time_fired_ts, states.context_id_bin AS context_id_bin, states.context_user_id_bin AS context_user_id_bin, states.context_parent_id_bin AS context_parent_id_bin, NULL AS shared_data, states.state_id AS state_id, states.state AS state, states_meta.entity_id AS entity_id, CASE JSON_EXTRACT(CAST(state_attributes.shared_attrs AS CHAR), '$.\"icon\"') WHEN 'null' THEN NULL ELSE JSON_UNQUOTE(JSON_EXTRACT(CAST(state_attributes.shared_attrs AS CHAR), '$.\"icon\"')) END AS icon, CASE JSON_EXTRACT(CAST(states.attributes AS CHAR), '$.\"icon\"') WHEN 'null' THEN NULL ELSE JSON_UNQUOTE(JSON_EXTRACT(CAST(states.attributes AS CHAR), '$.\"icon\"')) END AS old_format_icon, NULL AS context_only
FROM states FORCE INDEX (ix_states_metadata_id_last_updated_ts) LEFT OUTER JOIN states AS old_state ON states.old_state_id = old_state.state_id LEFT OUTER JOIN state_attributes ON states.attributes_id = state_attributes.attributes_id LEFT OUTER JOIN states_meta ON states.metadata_id = states_meta.metadata_id
WHERE states.last_updated_ts > 1680643068.831e0 AND states.last_updated_ts < 1681560448.005736e0 AND old_state.state_id IS NOT NULL AND states.state != old_state.state AND states.state IS NOT NULL AND ((states_meta.entity_id NOT LIKE 'proximity.%' AND states_meta.entity_id NOT LIKE 'counter.%' AND states_meta.entity_id NOT LIKE 'sensor.%') OR ((states_meta.entity_id LIKE 'sensor.%') AND (state_attributes.shared_attrs NOT LIKE '%\"unit_of_measurement\":%' OR states.attributes NOT LIKE '%\"unit_of_measurement\":%'))) AND (states.last_updated_ts = states.last_changed_ts OR states.last_changed_ts IS NULL) AND states.metadata_id IN (5, 393, 373, 381, 382, 371, 365, 370, 372, 396, 383, 384, 3, 366, 380, 367, 368, 375, 374, 83, 389, 385, 376, 209) UNION ALL SELECT events.event_id AS event_id, event_types.event_type AS event_type, events.event_data AS event_data, events.time_fired_ts AS time_fired_ts, events.context_id_bin AS context_id_bin, events.context_user_id_bin AS context_user_id_bin, events.context_parent_id_bin AS context_parent_id_bin, event_data.shared_data AS shared_data, 0 AS state_id, NULL AS state, NULL AS entity_id, NULL AS icon, NULL AS old_format_icon, '1' AS context_only
FROM anon_1 LEFT OUTER JOIN events FORCE INDEX (ix_events_context_id_bin) ON anon_1.context_id_bin = events.context_id_bin LEFT OUTER JOIN event_types ON events.event_type_id = event_types.event_type_id LEFT OUTER JOIN event_data ON events.data_id = event_data.data_id UNION ALL SELECT NULL AS event_id, NULL AS event_type, NULL AS event_data, states.last_updated_ts AS time_fired_ts, states.context_id_bin AS context_id_bin, states.context_user_id_bin AS context_user_id_bin, states.context_parent_id_bin AS context_parent_id_bin, NULL AS shared_data, states.state_id AS state_id, states.state AS state, states_meta.entity_id AS entity_id, NULL AS icon, NULL AS old_format_icon, '1' AS context_only
FROM anon_1 LEFT OUTER JOIN states FORCE INDEX (ix_states_context_id_bin) ON anon_1.context_id_bin = states.context_id_bin LEFT OUTER JOIN states_meta ON states.metadata_id = states_meta.metadata_id ORDER BY time_fired_ts
Are they related to the migration process ?
On discord someone told me that I should have a notification for the migration process in the frontend, I never see it.
Is there any way to redo the migration process, maybe it has failed for me ?
Thank you for your help.