core icon indicating copy to clipboard operation
core copied to clipboard

The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly

Open glc650 opened this issue 1 year ago • 48 comments

The problem

Since updating to core 2024.1.6 I get this in the log whenever I restart/power on my HA box or simply restart HA:

2024-02-01 16:48:16.527 WARNING (Recorder) [homeassistant.components.recorder.util] The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly

Never seen this in the logs until 2024.1.6. I always use Settings > 3 dot menu > Restart Home Assistant.

What version of Home Assistant Core has the issue?

2024.1.6

What was the last working version of Home Assistant Core?

2024.1.5

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

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

glc650 avatar Feb 02 '24 01:02 glc650

This warning is quite common for me for quite some time. Usually it does happen after abrupt restart of my machine (running Virtual appliance of HAOS in VMWare), but I guess it shouldn't happen after normal HA restart like it does for you.

oopiicaa avatar Feb 02 '24 07:02 oopiicaa

I've never done anything but a graceful restart or shutdown so I don't know why I'm seeing it.

glc650 avatar Feb 02 '24 08:02 glc650

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (recorder) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of recorder can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign recorder Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


recorder documentation recorder source (message by IssueLinks)

home-assistant[bot] avatar Feb 02 '24 12:02 home-assistant[bot]

Same problem for me I noted this issue since core 2024.1.1 and now it goes on 2024.1.6. Never shuttted down abruptly; daily clean host.shutdown. Before restarting, daily clean database (1 hour before) I tried to erase the db and starting a new one but the issue is still there.

I use HAOS in a VMware environment

Logger: homeassistant.components.recorder.util
Source: components/recorder/util.py:332
Integration: Recorder (documentation, issues)
First occurred: 00:59:07 (1 occurrences)
Last logged: 00:59:07

The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly

Deimos761 avatar Feb 07 '24 17:02 Deimos761

Same here, I am deploying in microk8s with a nfs volume, locking the version to 2023.12.4 resolved the issue right away

pierrecabral avatar Feb 09 '24 04:02 pierrecabral

yesterday night I tried to add a recorder.disable line to the automation that shuts down my system every night, in order to temporarily stop reading/writing the database but this workaround did not had any effect, apparently: this morning, the message was still there.

EDIT: even deleting the old db and creating a new one...

Deimos761 avatar Feb 09 '24 07:02 Deimos761

I have a brand new install, using the Proxmox-VE Helper Script and I am stuck at core 2024.1.5.

I even tried to update to version 2024.1.6 with no luck.

After I initiate the update, a short time passes and the whole HA OS shuts down and never starts again.

mrosun avatar Feb 10 '24 21:02 mrosun

Same warning in logs here.

rpi3-64 with HAOS 11.5 2024.1.6

Cannot update to 2024.2.2 (infinite loading), don't know if it's related.

Logger: homeassistant.components.recorder.util
Source: components/recorder/util.py:332
Integration: Recorder (documentation, issues)
First occurred: 13:15:39 (1 occurrences)
Last logged: 13:15:39

The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly

bombaata avatar Feb 17 '24 12:02 bombaata

The same goes for me. It comes every time HA OS reboots

Logger: homeassistant.components.recorder.util Source: components/recorder/util.py:332 Integration: Recorder (documentation, issues) First occurred: 11:34:01 (1 occurrences) Last logged: 11:34:01

The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly

olli711 avatar Mar 02 '24 10:03 olli711

Is there a way to manually flip whatever flag keeps causing this?

eshicks4 avatar Apr 22 '24 15:04 eshicks4

I've got the same problem. My HomeAssistant (Docker on CasaOS) Installation will suddenly crash and come back on relatively quick but sometimes it just stays off and my nuc gets really hot. logs

xandalo avatar May 05 '24 19:05 xandalo

same here. HA restart itself every 50-60 minutes.

Memory or cpu usage looks normal

image

cataseven avatar May 28 '24 13:05 cataseven

Same here..

mathgim avatar Jun 03 '24 06:06 mathgim

Same Issue here...

rsg117 avatar Jun 06 '24 13:06 rsg117

Same issue for me. I have an Intel N100 system running Ubuntu as host for VMware with HAOS image. Since this problem occurred, HAOS does not run in a stable way. When booting, sometimes it hangs - no web access possible. Are there any hints to fix this issue?

squonk11 avatar Jun 10 '24 16:06 squonk11

same here. HA restart itself every 50-60 minutes.

Memory or cpu usage looks normal

image

Usually its a bad integration flooding the system when you see graphs like that. Please see https://community.home-assistant.io/t/2024-5-tracking-down-instability-issues-caused-by-integrations/724441

bdraco avatar Jun 10 '24 17:06 bdraco

Same problem and HA restarts every 5-10 minutes or less

Deploying as VM in Proxmox

gtrabanco avatar Jul 07 '24 17:07 gtrabanco

Same. I finally started from scratch to get a working HA instance (HAOS) on VirtualBox. It's been great for about a month, but since the update to 2024.7.2, it restarts at least once a day. When back online, template sensors are unrecognized (even received an error that {% elif %} was unrecognized. ?? ) I restarted in safe mode, and then restarted in normal mode and didn't receive the following errors in the log, but 2/3 of the custom Lovelace integrations (HACS) didn't load.

Logger: homeassistant.components.recorder.util Source: components/recorder/util.py:331 integration: Recorder (documentation, issues) First occurred: 6:30:05 PM (1 occurrences) Last logged: 6:30:05 PM

The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly

FOLLOWED BY

Logger: homeassistant.components.recorder.util Source: components/recorder/util.py:610 integration: Recorder (documentation, issues) First occurred: 6:30:08 PM (1 occurrences) Last logged: 6:30:08 PM

Ended unfinished session (id=51 from 2024-07-11 22:59:46.069835)

FOLLOWED BY

Logger: homeassistant.config_entries Source: config_entries.py:586 First occurred: 6:32:09 PM (1 occurrences) Last logged: 6:32:09 PM

Error setting up entry Supervisor for hassio Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 1147, in async_get_platforms await self.hass.async_add_import_executor_job( asyncio.exceptions.CancelledError: Global task timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/hassio/init.py", line 536, in async_setup_entry await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2059, in async_forward_entry_setups await self._async_forward_entry_setups_locked(entry, platforms) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2070, in _async_forward_entry_setups_locked await asyncio.gather( File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2135, in _async_forward_entry_setup result = await async_setup_component( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/setup.py", line 187, in async_setup_component await future File "/usr/src/homeassistant/homeassistant/setup.py", line 167, in async_setup_component result = await _async_setup_component(hass, domain, config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/setup.py", line 327, in _async_setup_component integration_config_info = await conf_util.async_process_component_config( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config.py", line 1641, in async_process_component_config for validated_config in await asyncio.gather( ^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config.py", line 1407, in _async_load_and_validate_platform_integration platform = await p_integration.integration.async_get_platform(domain) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1100, in async_get_platform platforms = await self.async_get_platforms((platform_name,)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1172, in async_get_platforms import_future.set_exception(ex) asyncio.exceptions.InvalidStateError: invalid state

TymoSF avatar Jul 12 '24 04:07 TymoSF

I restarted in safe mode, and then restarted in normal mode and didn't receive the following errors in the log,

That indicates a problem with a custom component.

Global task timeout indicates some custom component is blocking startup long enough that startup times out and causes the platform load to fail.

Please download and post the complete log https://my.home-assistant.io/redirect/logs

bdraco avatar Jul 12 '24 05:07 bdraco

Same problem and HA restarts every 5-10 minutes or less

Deploying as VM in Proxmox

In my case was due Proxmox ping monitor. Add HA to the exception list was the solution.

gtrabanco avatar Jul 12 '24 16:07 gtrabanco

I restarted in safe mode, and then restarted in normal mode and didn't receive the following errors in the log,

That indicates a problem with a custom component.

Global task timeout indicates some custom component is blocking startup long enough that startup times out and causes the platform load to fail.

Please download and post the complete log https://my.home-assistant.io/redirect/logs

I'm having this issue. Please see my log attached. Running as a VM on Unraid. My recorder stops running after a few hours. My backups have been growing in size a bunch too. The database is about 4gb uncompressed.

home-assistant_2024-07-12T18-17-25.082Z.log

image

image

ryanwalexander avatar Jul 12 '24 18:07 ryanwalexander

I'm running home-assistant in Docker on Ubuntu 24.04. I noticed that when running docker stop I see the SIGTERM signals blocked by apparmor. I think this is why home-assistant is not able to gracefully shutdown and leaves the sqlite db in an unclean state.

[47814.419877] audit: type=1400 audit(1720838394.299:115): apparmor="DENIED" operation="signal" class="signal" profile="docker-default" pid=3821 comm="runc" requested_mask="receive" denied_mask="receive" signal=term peer="runc"
[47816.507821] audit: type=1400 audit(1720838396.387:116): apparmor="DENIED" operation="signal" class="signal" profile="docker-default" pid=3831 comm="runc" requested_mask="receive" denied_mask="receive" signal=kill peer="runc"

This led me to https://github.com/moby/moby/pull/47749 which explains how the runc profile changed in apparmor 4.0.0 and might not match the runc path used in docker.

It looks like this will be fixed upstream and eventually make it down to distros, but you can work around the issue by updating the /etc/apparmor.d/runc profile. Change the profile line /usr/sbin/runc -> /usr/{sbin,bin}/runc so the profile will be applied to processes run with either binary. After changing the profile, restart apparmor sudo systemctl restart apparmor. After that I can restart home-assistant and I no longer see the unclean warning.

This fix seems specific to runc and containers, so I don't know if it work for all the different ways folks are running home-assistant, but hopefully a hint.

FWIW, I'm not seeing any significant memory usage, so I think the folks seeing unclean shutdowns from out-of-memory, those are really a separate issue from folks trying a voluntary restart. Take a look at dmesg for oom_killer.

adborden avatar Jul 13 '24 05:07 adborden

@adborden Got the same problem here running HAOS in a Proxmox VM on a Dell Optiplex 3050. I'd give this a go, but I can't find a file named /etc/apparmor.d/runc to edit. I'm assuming I have to ssh into HAOS itself to do this, which I have, but no sign of such a file.

image

ProphetOfDoom avatar Jul 17 '24 15:07 ProphetOfDoom

@adborden Got the same problem here running HAOS in a Proxmox VM on a Dell Optiplex 3050. I'd give this a go, but I can't find a file named /etc/apparmor.d/runc to edit. I'm assuming I have to ssh into HAOS itself to do this, which I have, but no sign of such a file.

image

Make sure you have disabled the proxmox monitoring. At least for HAOS VM.

gtrabanco avatar Jul 17 '24 15:07 gtrabanco

@adborden You mean this Proxmox VM setting? I've only just enabled it an hour or so ago and pretty sure I was getting the SqlLite error message before doing so.

image

ProphetOfDoom avatar Jul 17 '24 16:07 ProphetOfDoom

I personally run HAOS directly on Raspberry Pi4 (no docker). I have two instances (two independent HAOS on two RPi4 for two distinct usages). And I face the problem on both of them. Here is the full log file of one of them. home-assistant_2024-07-18T07-32-40.136Z.log

mathgim avatar Jul 18 '24 07:07 mathgim

I'll echo what everybody else is saying.. same issue here. @homeassistant can someone please look into this?

Also, I want to add that in this comment https://github.com/home-assistant/core/issues/109343#issuecomment-1923727618 the bot attempted to @homeassistant/core which is not a thing, it should be @homeassistant .

NeckBeardPrince avatar Jul 18 '24 23:07 NeckBeardPrince

I am still having the same problem: The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly and Ended unfinished session (id=51 from 2024-07-19...

Now I tried to restart in safe mode. But it has the same result: haos (or VM?) does not stop. I kill the VM with "poweroff". Then I have to force an emergency-stop of the VM using VBoxManage startvm "haos" --type emergencystop because the virtual machine did not stop correctly. After restart I see again the above error messages in the log. That means: the custom addons are not the problem.

squonk11 avatar Jul 19 '24 14:07 squonk11

Also got this, but related to #121854

Sebazzz avatar Jul 20 '24 10:07 Sebazzz

Same here. Ubuntu 20.04 on Docker.

floppy-disk avatar Jul 20 '24 18:07 floppy-disk