PSA: 2024.7 recorder problems

Something is preventing your database session from closing.

2024-07-06 04:34:40.785 WARNING (MainThread) [homeassistant.core] Timed out waiting for final writes to complete, the shutdown will continue
2024-07-06 04:34:40.785 WARNING (MainThread) [homeassistant.core] Shutdown stage 'final write': still running:

Same here. Non of the mentioned integrations recorder stops at 4:00 after upgrading to 2024.7

1 Like

According to Purge causes recorder to stop writing to the DB until HA is restarted · Issue #117263 · home-assistant/core · GitHub this issue will be resolved in 2024.8.0 and, as I understand, can be caused by custom integrations AND/OR old databases with some unsupported foreign keys in the states table.

It has been fixed, just not available for general release yet as it is a big change and needs more general testing first.

Either way, it looks best to do the suggested

recorder:
  auto_purge: false

until this is released.

9 Likes

Thank you, good to read. I will try the suggestion.

I can confirm that temporarily deactivating the “purge” works. So I will just leave it as it is right now and then reactivate the purge after 2024.8

1 Like

Well, if it’s that important to you, then here you go. Just be aware though, that I don’t use all of those, some are downloaded and not installed.

I doubt that is going to help anyone though, as the issue is 99% certain to be the “special characters” that somehow suddenly upset the Purge.

1 Like

I don’t think that’s a problem, the history graphs open in a blink of an eye. I exclude most of the entities.

Would calling the purge service after a 2024.7.x update definitively prove whether or not my database is subject to this problem, or could it still happen later, at the 4 AM auto-purge?

1 Like

Normally the manual purge should trigger the issue. Run the service, wait half an hour and then check the logs and your entity statistics and see if anything got stuck. That’s the procedure as far as I am aware.

2 Likes

I fit into the catagory who has none of the known problem integrations, but has the problem after the 2024.7.1 upgrade, not fixed with the 2024.7.2 update. So I rolled back to 2024.6.4 and the problem was fixed.

I will keep watching this space and not updated until there is some evidence the 2024.8 (or something else) fixes the issue. For me it was not an option to stay with 2024.7, as by then with lots of entities, the db size would have grown and filled the disk.

3 Likes

I’ve had the same problem since the 2024.7.x
I’m not using the 3 integrations mentioned up top. These are the integrations I’ve got enabled.

1 Like

There’s 2 separate issues. Which one do you have?

This thread was created to address issues caused by custom integrations that @tom_l has highlighted.

Separately, there’s an influx of people who have a separate (older) issue related to purge that will be addressed in 2024.8. That issue was not created by this release, it’s just more apparent with this release.

If you have issues related to purge, please check out the issue linked above. Otherwise, this is not the correct thread.

4 Likes

Thanks for clarifying @petro

Same with me!

Just for clarity, why is the issue more apparent with this release? I have two installs, one old one that has been upgraded for years which has the DB issue, but the other (newer Install) has not.

Is it just more apparent because the history / recorder stalls in this release? What was the issue before?

Sorry for nagging. I just want to understand.

3 Likes

Yes this is a good workaround, thank you.

There are some HA which start 2 or 3 years ago where the schema of the DB is involving. Like mine, starting in 2021 with schema version 23 where we are now in version 43. There was no issue till an update coming with 2024.7 of Alpine version that cause sqlite dependencies and locking of database.
It’s not core HA code change or sql code purge change.
For those old db, even with new schema, they still have some difference in table (index, keys) . I’m not a DBA but it’s what I understood.

So now migration script will have to recreate some tables to remove those parts which is no more used but remains. It’s a risky process and sqlite have define some steps (12) for that where thanks to @bdraco try to resolve.

I hope this is more clear for everybody :wink:

details here : Purge causes recorder to stop writing to the DB until HA is restarted (Auto purge happens at 4:12am) · Issue #117263 · home-assistant/core · GitHub

Solution (you need to consider this for advanced users/own risk - backup and check to have enough free disk space of course !
It’s solve the issue on mine.

Link: Purge causes recorder to stop writing to the DB until HA is restarted (Auto purge happens at 4:12am) · Issue #117263 · home-assistant/core · GitHub

3 Likes

Hi,
I encountered (probably the 1st issue).
Is there a way to write an automation to get a notification (that part I know how to do) when the recorder stops working? (that part I don’t)…
D.

yes, possible via a check on CPU usage and memory increasing.

2 Likes

It’s more apparent because more people are hitting it. The bug existed long before this release but there wasn’t enough people/information to figure out what the problem was. Just take a look at the linked issue and you’ll get a history dating back before this release.

1 Like