-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recorder warns sqlite3 was not shutdown cleanly, despite controlled shutdown #73679
Comments
recorder documentation |
Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration ( |
I have the same problem, is there any news about it? Many thanks |
I guess the issue is, that core now doing online database migration. We need a way to get the information on the supervisor to prevent shutdown/reboots while core migrates live the database. Maybe it's also an issue with sqlite. Coult be that the python 3.10 upgrade solve that in 2022.7 |
Thanks for the info @pvizeli! The issue remains in the 2022.7.x series and on HAOS 8.2. In my experience it's very consistent – IIRC anytime I've done a controlled shutdown via the UI, the sqlite warning shows up in the logs. |
Same issue here with Supervisor 2022.07.0 and HA 2022.8.3. |
I also have this error but usually after shutting down/restarting my Synology NAS. HA 2022.7.6 running inside Docker. |
I have the same problem after restarting HA from GUI, have to reboot the VM. Have recently moved my VM to a new host and get a corrupt db-file. Home Assistant 2022.10.5 |
Same here (docker)
|
If you shutdown via docker you can hit the container shutdown timeout (I think its 10 seconds) which causes an abrupt shutdown as it does not give Home Assistant enough time to properly shutdown |
I use VMWare Workstation and I get this error every time I restart the VM. HASOS is shutting down cleanly.
|
I also checked my docker env: shutdown timeout: 120sec. HA is done earlier but the message keeps popping up (sometimes, not always). |
Same issue here. Does anyone has a workaround with the exception of removing that database and let it regenerate it (it keeps reboot and appear after some days)? |
We need a full log from the run before the issue appears with debug logging turned on for I also opened #91261 which will cause the recorder to try to shutdown cleanly if something really goes wrong. |
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. |
Issue still there. |
I am experiencing the same issue running HA on Docker. I run HAnon unRAID and I take nightly backups of all of the Docker volumes (there is an unRAID plugin that makes common practice). The backup process logs show the HA container was stopped in 10 seconds while I have the timeout set at 120 seconds. Not really sure what's going on here. I can check the logs from the HA container this weekend. Any advice on what to look for? I can also try moving to MariaDB but it would be nice to get some insight into this issue. |
I was having this problem, new installations or restored, after reboot HA did not start. I changed my sd card and problem stop. |
I'm using Home Assistant OS on a Home Assistant Yellow and get this error every time I power on HA. I'm always use the UI to do a clean shut down. I do this quite often as I'm still playing around. |
Also experiencing this issue using docker image homeassistant/home-assistant:2024.1 |
Same problem for me I use HAOS in a VMware environment
|
In HA 2024.2 when node-red issues the host_shutdown service I also get this log. |
Hi all. Proxmox 8.1.4 Core 2024.2.5 i have these 2 entries in log: Logger: homeassistant.components.recorder.util Ended unfinished session (id=312 from 2024-03-01 15:47:50.708938) Logger: homeassistant.components.recorder.util The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly |
I have the issue on the 2024.04.03 on my supervised installation as well. I realized it during the development of the custom integration. If I restart HA (from the web menu) after it was running from the previous day (means more than ~ ten hours) I will get same error after HA restart:
The HA shutdown phase seems to be very long (very close to 300s / 5min) and there is nothing in the logs after HA restart is triggered (with normal warning log level). Is there any 5min shutdown timeout? Can it be extended? But if I restart HA after it was running only for few tens of minutes (up to hour or two), the restart is almost immediate. I use HA on supervised installation on server hardware, with SQLite being placed on NVMe disk, so bare HW performance shall not be an issue, even with my DB size around 1GB. @bdraco: I just started HA recorder with debug set, but due to said above to reproduce error I will need to keep it running for some time and therefore the produced log would be huge. I am also not completely comfortable to share all the data publicly. Is there anything we can do about it? Thank you. |
It seems like you have something blocking shutdown which is why it gives up and shuts down uncleanly. You might be able enable debug logs for homeassistant.core, and than down a shutdown to reveal what it is waiting for |
I installed HomeAssistant using the WSL instructions in Windows 11's WSL2 Ubuntu 24.04 LTS. The UI at localhost:8123 (homeassistant.local:8123 wasn't working) doesn't have a shutdown option. Under http://localhost:8123/config/system I only see Restart. So I've been seeing: dlamblin@whitebox:~$ cat start-home-assistant.sh
sudo -u homeassistant -H -s source /srv/homeassistant/bin/activate-with-hass
dlamblin@whitebox:~$ . start-home-assistant.sh
[sudo] password for dlamblin:
2024-05-23 10:23:13.189 WARNING (Recorder) [homeassistant.components.recorder.util] The system could not validate that the sqlite3 database at //home/homeassistant/.homeassistant/home-assistant_v2.db was shutdown cleanly
2024-05-23 10:23:29.662 ERROR (SyncWorker_5) [aiodhcpwatcher] Cannot watch for dhcp packets without a functional packet filter: libpcap is not available. Cannot compile filter ! And I'm unsure how I'd avoid it. Choosing reset does actually exit the running process above. And it doesn't appear to restart. activate-with-hass is just the venv activate script with |
@bdraco thank you for guidance, but I am lost.
The GUI stop responding immediately when I execute restart (full restart), so using profile after that is not an option. I did installed profiles and executed: I am attaching log. For the first two I do not see any obvious issue, number of pending threads seems to be OK to my usage, also the scheduled event loop seems to be fine as well. When I execute restart, there is almost nothing to be logged in the HA log, except for:
this is the end of the log, nothing else is logged! Then HA is restarted after ~4-5 minutes and complains about not properly closed DB. LOG_EVENT_LOOP_SCHEDULED.log |
I added a new service in 2024.6.0 https://my.home-assistant.io/redirect/developer_call_service?service=profiler.log_current_tasks https://next.home-assistant.io/integrations/profiler/#service-profilerlog_current_tasks |
Thank you, I will use it once 2024.6.0 is ready and post results here. |
Thank you for update profiler. Using new profiler service Please disregard my previous post, as my log was not complete list of the asyncio task. I edited my post to delete it. I will try to post here when I will find hopefully blocking tasks tomorrow |
One thing to keep in mind is that all tasks are not blocking ones, only tasks created with Its a bit of work to figure out where they were created, but once you have a list of tasks, usually you can use the name of the task to figure out where it was created and than work backwards to figure out if its a tracked (one that will block shutdown) or untracked task. |
Thank you for additional information, just where I will see how the task were created? |
Its a bit of digging to work it out. Once you have the name/location of the task, you have to search out the code that created the task. Usually you can checkout |
Ok, no problem I can do that, |
OK, I just did:
The whole log is attached, some findings:
seems too many tasks for modbus sensors updates exists. I would expect, that if task is created to update modbus sensors, timeout shall exists to cancel the task if either timeout is reached or new succeeding task to update same sensor is created. So ModbusRegisterSensor.async_update tasks seems to be growing constantly...
is seems, that Kodi HA native integration is unable to cleanly handle HA shutdown
@bdraco where do you please suggest to start? |
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. |
still pending |
Still happening on HA GREEN Platform Versions: HA OS:13.1 and HA CORE: 2024.10.0
|
Same here, problem is present after any restart after more than few hours of HA uptime. |
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. |
Still going on for me |
@bdraco please can you help us here? It would be really nice to get repetitive process dump during the HA stop - to see what is still running and preventing HA to stop/restart properly. This problem still persists and affect multiple users. I fully understand that it can be caused by 3rd party integration, so I am not asking for fix, but to implement code, which would help to identify component causing this issue. This would significantly help to all community also for the future similar issues. So far we were not able to identify root cause using current profiler implementation. I am fully ready to test any code - I have full control over my HA (Supervised) so I can patch HA code easily. Thank you very much in adance, |
Maybe I am wrong but I am actually not fully convinced that the problem can be caused by 3rd party integration: I did a clean installation of HA (supervised on VMware) and the problem was there almost immediately. |
Do you by any chance use native modbus or any other modbus based integration? During my troubleshooting with the profiler I caught many pending scheduler modbus tasks. |
In my case, the problem occurs particularly after an Internet outage. |
And do you have any internet based integration? And in addition n do you suffer the same issue as me, so HA restart takes about 4-5min? (After hitting restart the HA becomes unresponsive immediately and will start only after 4-5 minutes) |
in my case, not any integration based on internet (at the time of the first error messages of sqlite3). |
And the slow restart.as I described? Do you have this issue as well? |
no: the performance itself seems not to be affected, in my case |
Neither me. |
I am using HA Yellow without any fiddling with modbus (whatever that may be). The restart time seems to be normal. At least it does not take so long that I start to get worried :) |
The problem
Recently, I often but not always get a warning that the Recorder's default sqlite3 DB was not shutdown cleanly. This is despite performing a controlled shutdown via the UI on the Hardware settings page.
Currently running 2022.6.x and HAOS 8.1. This issue started within the past month or so. Hard for me to pinpoint if it's correlated with HAOS 8.x or the Core version.
I have a feeling this issue will need to be moved to the HAOS repo, but the direct problem that is logged is from Recorder.
I have run HAOS in a VM for a few years (OVA image running within KVM on Proxmox). I always shut it down from within the HAOS guest via the UI.
I am sure there are more diagnostics I can help pull, I am not sure where to start.
Thank you teams!
What version of Home Assistant Core has the issue?
core-2022.6.6
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Recorder
Link to integration documentation on our website
https://www.home-assistant.io/integrations/recorder/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: