mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +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)
|
||||
|
||||
# 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")
|
||||
self.hass.add_job(self._async_set_recorder_ready_migration_done)
|
||||
self._run_event_loop()
|
||||
@ -1118,7 +1122,6 @@ class Recorder(threading.Thread):
|
||||
with session_scope(session=self.get_session()) as session:
|
||||
end_incomplete_runs(session, self.run_history.recording_start)
|
||||
self.run_history.start(session)
|
||||
self._schedule_compile_missing_statistics(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.__cause__ = sqlite3.DatabaseError()
|
||||
|
||||
await async_wait_recording_done(hass)
|
||||
with patch.object(
|
||||
get_instance(hass).event_session,
|
||||
"close",
|
||||
|
@ -336,6 +336,8 @@ async def test_schema_migrate(hass, start_version, live):
|
||||
), patch(
|
||||
"homeassistant.components.recorder.migration._apply_update",
|
||||
wraps=_instrument_apply_update,
|
||||
), patch(
|
||||
"homeassistant.components.recorder.Recorder._schedule_compile_missing_statistics",
|
||||
):
|
||||
recorder_helper.async_initialize_recorder(hass)
|
||||
hass.async_create_task(
|
||||
|
Loading…
x
Reference in New Issue
Block a user