Sensor state changes not written to DB, not showing on history graph

I just started to experience very strange issue with history of few sensors not being properly written tohistory. For example I have sensor that shows status of my Automover (it is relay switch installed in base station, so I know if mover is in base or out). Current state of sensor shows that it is out of base for more than 2 hours, so alarm was triggered and is properly reflected as current sensor state. On the other hand history bar linked to the same sensor does not show state change, but previous one (on picture below blue indicates mover is working, while status in reality is ‘Did not return to base’:
image

Moment later I returned mover manually to the base and suprisingly status changed… but not the way I’d expect… Now status is correct (Charging), but history bar is showing that it does not returned to base (so previous state), starting at the moment that alarm was triggered (so recorded properly)… but it is missing event of mover returning to base.
image
It looks that history bar now shows events with ‘one event delay’ for the lack of better description.
It is also somehow consistent, not only history card, but also History page shows the same problem.
Also most of my motion sensors behaves the same way now. They trigger the action if needed, but do not register properly in history. I’m using HA as VM running on ESXi server with history kept in MariaDB on Synology NAS, without problems so far. Issue noted after update to 0.113.3, but I’m not sure if this might be related… Any idea?

I made some more troubleshooting:

  • restart of HA resolves issues, events start to be properly recorded
  • every morning next day issue is back again with events not being recorded or showing with delay
  • history graphs frequently shows History not found, sometime it is required to reload page few times to get the chart.
  • history purge also stopped to work (I think) I have recorder configured to keep 31 days but now I see entries in DB that are 33 days old.

Initially my thought was that this might be related to some sort of DB corruption, but log does not show any errors/warnings related to DB. Also restart of HA would not resolve issue, if it would be on DB side.
This leads me really to thinking that there is something wrong with 0.103.3, which introduced this problem for me (though in release notes I do not see anything related to DB handling).
BTW I noticed few more posts recently on forum, describing similar issues - no history data or missing some periods in history.