Recorder SQL error

this is a secord morning I find such messages untill I reboot HA. Everithing seems working except some weird behavior of tasmota switches… So, these are the error msg most often appear in the log:

Logger: homeassistant.components.recorder
Source: components/recorder/__init__.py:497
Integration: Recorder (documentation, issues)
First occurred: 4:12:02 AM (17787 occurrences)
Last logged: 9:33:16 AM

Error saving events: Instance <States at 0xa6aab598> is not present in this Session
Error saving events: Instance <States at 0xa6c20e08> is not present in this Session
Error saving events: Instance <States at 0xad87cbc8> is not present in this Session
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 442, in _commit_event_session_or_retry
    self._commit_event_session()
  File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 497, in _commit_event_session
    self.event_session.expunge(dbstate)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 1854, in expunge
    raise sa_exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Instance <States at 0xa6aab598> is not present in this Session
Logger: homeassistant.components.recorder
Source: components/recorder/__init__.py:501
Integration: Recorder
First occurred: 4:12:02 AM (19271 occurrences)
Last logged: 9:33:16 AM

Error executing query: (sqlite3.IntegrityError) UNIQUE constraint failed: events.event_id [SQL: INSERT INTO events (event_id, event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)] [parameters: ((726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:28:43.037845', '2020-10-09 07:28:44.040473', '0f26c7670a0111ebaecacd10efa9b067', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:24:43.037207', '2020-10-09 07:24:44.041607', '801996890a0011ebae989745b71ce00a', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:20:43.036770', '2020-10-09 07:20:44.036252', 'f10c6d7b09ff11ebbd49b36ae4da4615', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:16:43.035882', '2020-10-09 07:16:44.038705', '61ff32d109ff11eb92f4b385eb1bab59', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:12:43.035372', '2020-10-09 07:12:44.041311', 'd2f206f009fe11eb879f97a7a297f4d8', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:08:43.034247', '2020-10-09 07:08:44.038226', '43e4c2f309fe11ebbb82255b5e3078b9', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:04:43.033272', '2020-10-09 07:04:44.038340', 'b4d784ac09fd11ebb07f9f870dc27b92', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:00:43.032535', '2020-10-09 07:00:44.039932', '25ca4ecd09fd11eb90b4bf2ead492b2b', None, None) ... displaying 10 of 77 total bound parameter sets ... (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 02:51:05.040720', '2020-10-09 02:51:06.011845', '46361ee209da11eb981ce30a573ff847', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 02:31:05.039703', '2020-10-09 02:31:06.021697', '7af47c5309d711eb938787f44a242e75', None, None))] (Background on this error at: http://sqlalche.me/e/13/gkpj)
Error executing query: Instance <States at 0xa6aab598> is not present in this Session
Error executing query: (sqlite3.IntegrityError) UNIQUE constraint failed: events.event_id [SQL: INSERT INTO events (event_id, event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)] [parameters: ((726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:32:00.201870', '2020-10-09 07:32:01.162172', '84ab9bb90a0111ebadd45b3ea9f34fad', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:31:00.199567', '2020-10-09 07:31:01.572009', '60e7fbab0a0111eb98a883d5c755c357', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:30:00.196731', '2020-10-09 07:30:01.150943', '3d24466a0a0111ebbd8d919455d05963', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:29:00.194594', '2020-10-09 07:29:01.153055', '1960ad9a0a0111ebb7b7a1d32048322d', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:28:00.192313', '2020-10-09 07:28:01.163092', 'f59d0e580a0011eb80d505badf08fba5', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:27:00.189419', '2020-10-09 07:27:01.159057', 'd1d957590a0011eb958e710ec55c51f8', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:26:00.186889', '2020-10-09 07:26:01.162272', 'ae15a8430a0011eb934f750d940d05f5', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:25:00.183517', '2020-10-09 07:25:01.162066', '8a51e4de0a0011eb82493d2d2723124b', None, None) ... displaying 10 of 320 total bound parameter sets ... (726921, 'state_changed', '{}', 'LOCAL', '2020-10-09 02:14:00.053759', '2020-10-09 07:02:01.259362', '1804103709d511eb96efb5da51ddedfe', None, None), (726634, 'state_changed', '{}', 'LOCAL', '2020-10-09 02:13:00.052256', '2020-10-09 02:13:01.348955', 'f4408f8c09d411ebaf65cf689c55e748', None, None))] (Background on this error at: http://sqlalche.me/e/13/gkpj)
Error executing query: Instance <States at 0xad87cbc8> is not present in this Session
Error executing query: (sqlite3.IntegrityError) UNIQUE constraint failed: events.event_id [SQL: INSERT INTO events (event_id, event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)] [parameters: ((726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:28:08.359076', '2020-10-09 07:28:09.028032', 'fa7b386f0a0011ebb75991f93e74813c', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:23:06.952004', '2020-10-09 07:23:07.021865', '46d41ce30a0011ebb8d88d7eddc430f4', None, None), (726633, 'state_changed', '{}', 'LOCAL', '2020-10-09 07:18:11.350008', '2020-10-09 07:18:12.013723', '96a2df2f09ff11eba277cd41f663f375', None, None))] (Background on this error at: http://sqlalche.me/e/13/gkpj)

I’m experiencing the same thing. For me it’s my Meross thermostat that does not work properly.

I encountered the same problem and opened an issue this morning: https://github.com/home-assistant/core/issues/41533

In my case the climate entities weren’t working correctly anymore…

Restarting HA “fixes” the problem, until it occurs again…
And I’m using mysql as a backend.

How do you find out what causes the issue? In my case there is no even an entry in logbook and log is huge to open it in browser , iam on RPi4

Should be fixed in 0.116.1?
For me it is.

EDIT:

Yeap… I have just upgraded… will see next morning when it usually occurs.

yeah looks like it. Guess I didn’t search correctly before opening an issue.
Will report back if it throws any more errors within the next 24 hours.