Add a commit interval setting to recorder (#32596)
* Add a commit interval setting to recorder * Make the default every 1s instead of immediate * See attached py-spy flamegraphs for why 1s * This avoids disk thrashing during event storms * Make Home Assistant significantly more responsive on busy systems * remove debug * Add commit forces for tests that expect commits to be immediate * Add commit forces for tests that expect commits to be immediate * make sure _trigger_db_commit is in the right place (all effective "wait_recording_done" calls) * De-duplicate wait_recording_done code
This commit is contained in:
1 parent
8a46d93be4
commit
3a680bf7b7
5 files changed
+124
-63
No files matched your search
@@ -1,6 +1,7 @@
|
||||
"""The tests for the logbook component."""
|
||||
# pylint: disable=protected-access,invalid-name
|
||||
from datetime import datetime, timedelta
|
||||
from functools import partial
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
@@ -35,6 +36,7 @@ from homeassistant.setup import async_setup_component, setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import get_test_home_assistant, init_recorder_component
|
||||
from tests.components.recorder.common import trigger_db_commit
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -1288,6 +1290,7 @@ async def test_logbook_view_period_entity(hass, hass_client):
|
||||
entity_id_second = "switch.second"
|
||||
hass.states.async_set(entity_id_second, STATE_OFF)
|
||||
hass.states.async_set(entity_id_second, STATE_ON)
|
||||
await hass.async_add_job(partial(trigger_db_commit, hass))
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_add_job(hass.data[recorder.DATA_INSTANCE].block_till_done)
|
||||
|
||||
|
||||
Reference in new issue
Block a user