mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Catch up with statistics after DB migration is done (#78469)
* Catch up with statistics after DB migration is done * Don't access the database from the event loop * Fix deadlocking test * Fix test
This commit is contained in:
parent
bcf01e8873
commit
0a1fd36e03
@ -615,6 +615,10 @@ class Recorder(threading.Thread):
|
|||||||
|
|
||||||
self.hass.add_job(self.async_set_db_ready)
|
self.hass.add_job(self.async_set_db_ready)
|
||||||
|
|
||||||
|
# Catch up with missed statistics
|
||||||
|
with session_scope(session=self.get_session()) as session:
|
||||||
|
self._schedule_compile_missing_statistics(session)
|
||||||
|
|
||||||
_LOGGER.debug("Recorder processing the queue")
|
_LOGGER.debug("Recorder processing the queue")
|
||||||
self.hass.add_job(self._async_set_recorder_ready_migration_done)
|
self.hass.add_job(self._async_set_recorder_ready_migration_done)
|
||||||
self._run_event_loop()
|
self._run_event_loop()
|
||||||
@ -1118,7 +1122,6 @@ class Recorder(threading.Thread):
|
|||||||
with session_scope(session=self.get_session()) as session:
|
with session_scope(session=self.get_session()) as session:
|
||||||
end_incomplete_runs(session, self.run_history.recording_start)
|
end_incomplete_runs(session, self.run_history.recording_start)
|
||||||
self.run_history.start(session)
|
self.run_history.start(session)
|
||||||
self._schedule_compile_missing_statistics(session)
|
|
||||||
|
|
||||||
self._open_event_session()
|
self._open_event_session()
|
||||||
|
|
||||||
|
@ -1272,6 +1272,7 @@ async def test_database_corruption_while_running(hass, tmpdir, caplog):
|
|||||||
sqlite3_exception = DatabaseError("statement", {}, [])
|
sqlite3_exception = DatabaseError("statement", {}, [])
|
||||||
sqlite3_exception.__cause__ = sqlite3.DatabaseError()
|
sqlite3_exception.__cause__ = sqlite3.DatabaseError()
|
||||||
|
|
||||||
|
await async_wait_recording_done(hass)
|
||||||
with patch.object(
|
with patch.object(
|
||||||
get_instance(hass).event_session,
|
get_instance(hass).event_session,
|
||||||
"close",
|
"close",
|
||||||
|
@ -336,6 +336,8 @@ async def test_schema_migrate(hass, start_version, live):
|
|||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.recorder.migration._apply_update",
|
"homeassistant.components.recorder.migration._apply_update",
|
||||||
wraps=_instrument_apply_update,
|
wraps=_instrument_apply_update,
|
||||||
|
), patch(
|
||||||
|
"homeassistant.components.recorder.Recorder._schedule_compile_missing_statistics",
|
||||||
):
|
):
|
||||||
recorder_helper.async_initialize_recorder(hass)
|
recorder_helper.async_initialize_recorder(hass)
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user