WTH is my Home Assistant install doing at midnight for 1.5 hours in the database?

I suspect this is some sort of maintenance, but it goes on for a very long time - 90 minutes … the MariaDB addon logs show the following:

[00:00:08] INFO: Lock tables using mariadb client...
[00:00:08] INFO: MariaDB tables locked.
[01:26:03] INFO: MariaDB tables unlocked.
[00:00:02] INFO: Lock tables using mariadb client...
[00:00:02] INFO: MariaDB tables locked.
[01:26:21] INFO: MariaDB tables unlocked.
[00:00:04] INFO: Lock tables using mariadb client...
[00:00:04] INFO: MariaDB tables locked.
[01:26:55] INFO: MariaDB tables unlocked.
[03:00:37] INFO: Lock tables using mariadb client...
[03:00:37] INFO: MariaDB tables locked.
[04:27:19] INFO: MariaDB tables unlocked.
[00:00:04] INFO: Lock tables using mariadb client...
[00:00:04] INFO: MariaDB tables locked.
[01:27:29] INFO: MariaDB tables unlocked.
[00:00:02] INFO: Lock tables using mariadb client...
[00:00:02] INFO: MariaDB tables locked.
[01:27:51] INFO: MariaDB tables unlocked.
[00:00:10] INFO: Lock tables using mariadb client...
[00:00:10] INFO: MariaDB tables locked.
[01:28:15] INFO: MariaDB tables unlocked.
[00:00:33] INFO: Lock tables using mariadb client...
[00:00:33] INFO: MariaDB tables locked.
[01:28:50] INFO: MariaDB tables unlocked.
[00:00:16] INFO: Lock tables using mariadb client...
[00:00:16] INFO: MariaDB tables locked.
[01:29:03] INFO: MariaDB tables unlocked.
[00:00:04] INFO: Lock tables using mariadb client...
[00:00:04] INFO: MariaDB tables locked.
[01:29:03] INFO: MariaDB tables unlocked.

As a result of this, data isn;t recorded during this period… and I discovered that unless I schedule a restart for just after this period, the data collection stops completely, and doesn’t restart on it’s own

Did you find a reason and fix for this?

I’m having the same issue - and I’m about ready to uninstall MariaDB as a result. The long maintenance (if that is what it is) periods are bad enough but it takes a restart to get it working again - and that is not always possible!

[23:00:00] INFO: Lock tables using mariadb client...
[23:00:00] INFO: MariaDB tables locked.
[01:01:35] INFO: MariaDB tables unlocked.
[23:00:00] INFO: Lock tables using mariadb client...
[23:00:00] INFO: MariaDB tables locked.
[01:04:39] INFO: MariaDB tables unlocked.
[23:00:00] INFO: Lock tables using mariadb client...
[23:00:00] INFO: MariaDB tables locked.
[01:05:58] INFO: MariaDB tables unlocked.
[23:00:00] INFO: Lock tables using mariadb client...
[23:00:00] INFO: MariaDB tables locked.
[01:06:47] INFO: MariaDB tables unlocked.
[23:00:00] INFO: Lock tables using mariadb client...
[23:00:00] INFO: MariaDB tables locked.
[01:08:08] INFO: MariaDB tables unlocked.
[23:00:00] INFO: Lock tables using mariadb client...
[23:00:00] INFO: MariaDB tables locked.
[01:08:19] INFO: MariaDB tables unlocked.

I’ve not been able to find a solution yet, unfortunately … also, and I’m not sure why (perhaps recent update?) but the maintenance is taking less time recently, looks like approx 45 minutes recently:

[00:00:02] INFO: Lock tables using mariadb client...
[00:00:02] INFO: MariaDB tables locked.
[00:46:30] INFO: MariaDB tables unlocked.
[00:00:01] INFO: Lock tables using mariadb client...
[00:00:01] INFO: MariaDB tables locked.
[00:47:21] INFO: MariaDB tables unlocked.
[00:00:02] INFO: Lock tables using mariadb client...
[00:00:02] INFO: MariaDB tables locked.
[00:48:56] INFO: MariaDB tables unlocked.

Having said that, the time does appear to be growing each iteration.
There are issues in the HA GH tracker which are related:

Do you also see the missing data collection? if so, perhaps add your voice to that issue as well? :slight_smile:

Do you have automated backup? This should happen when backing up the home assistant. But 90 minutes are too long, so home assistant instance cannot keep the data on memory until database becomes free again.

Play your recorder settings and start cleaning up some stuff.

Time grows because data grows

Just a thought and I could be way off.

YMMV

A while back I had issues with backups taking WAY too long. Reason for this was the database was growing in size at an alarming rate. I was basically adding too many records to the db and then holding onto them.

Solution was to limit the number of records by using the recorder/purge_keep_days in my configuration.yaml. It is possible to also exclude entities for data you want to retain for longer.

recorder:
  purge_keep_days: 30
  exclude:
    entities:
      - sensor.blah.blah