From 8fcee01db0543271cdbf0ef46ab028fa3eed1326 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 16 May 2022 18:03:02 -0500 Subject: [PATCH] Remove unnecessary flush from recorder (#71910) --- homeassistant/components/recorder/core.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/homeassistant/components/recorder/core.py b/homeassistant/components/recorder/core.py index ba0e5ba17d1..91dc0a27ead 100644 --- a/homeassistant/components/recorder/core.py +++ b/homeassistant/components/recorder/core.py @@ -847,15 +847,14 @@ class Recorder(threading.Thread): assert self.event_session is not None self._commits_without_expire += 1 + self.event_session.commit() if self._pending_expunge: - self.event_session.flush() for dbstate in self._pending_expunge: # Expunge the state so its not expired # until we use it later for dbstate.old_state if dbstate in self.event_session: self.event_session.expunge(dbstate) self._pending_expunge = [] - self.event_session.commit() # We just committed the state attributes to the database # and we now know the attributes_ids. We can save