home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.6k stars 30.37k forks source link

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

Open ddong3000 opened 5 days ago

ddong3000 commented 5 days ago

The problem

Why won't it fix this? I'm having this problem too. It reboots several times every hour. How do I fix this?

제목 없음

System Information

version core-2024.10.1
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.4
os_name Linux
os_version 6.6.31-haos-raspi
arch aarch64
timezone Asia/Seoul
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok HACS Data | ok GitHub API Calls Remaining | 4999 Installed Version | 2.0.1 Stage | running Available Repositories | 1437 Downloaded Repositories | 12
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 13.1 -- | -- update_channel | stable supervisor_version | supervisor-2024.10.0 agent_version | 1.6.0 docker_version | 26.1.4 disk_total | 116.5 GB disk_used | 13.3 GB healthy | true supported | true host_connectivity | true supervisor_connectivity | true ntp_synchronized | true virtualization | board | rpi3-64 supervisor_api | ok version_api | ok installed_addons | File editor (5.8.0), Terminal & SSH (9.15.0), Matter Server (6.6.0)
Dashboards dashboards | 2 -- | -- resources | 4 views | 4 mode | storage
Recorder oldest_recorder_run | October 11, 2024 at 12:36 AM -- | -- current_recorder_run | October 11, 2024 at 12:10 PM estimated_db_size | 1.55 MiB database_engine | sqlite database_version | 3.45.3
Sonoff version | 3.8.1 (ffa7e22) -- | -- cloud_online | 1 / 1 local_online | 1 / 1

What version of Home Assistant Core has the issue?

What was the last working version of Home Assistant Core?

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Link to integration documentation on our website

Diagnostics information

Anything in the logs that might be useful for us?

Additional information

mib1185 commented 5 days ago

Why won't it fix this? I'm having this problem too. It reboots several times every hour. How do I fix this?

this is looks somehow weird - did you copy this from another issue report or forum post?

Anyway, if i only consider " It reboots several times every hour." as the issue description, i would guess, you HA restarts unexpected every hour? if yes, please provide the homeassistant.log.1 from the /config folder of your HA instance. This is always the logfile from the last run (before the system restarts)

ddong3000 commented 5 days ago

Why won't it fix this? I'm having this problem too. It reboots several times every hour. How do I fix this?

this is looks somehow weird - did you copy this from another issue report or forum post?

Anyway, if i only consider " It reboots several times every hour." as the issue description, i would guess, you HA restarts unexpected every hour? if yes, please provide the homeassistant.log.1 from the /config folder of your HA instance. This is always the logfile from the last run (before the system restarts)

2024-10-11 18:50:26.818 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration sonoff which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-10-11 18:50:26.824 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration air_korea which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-10-11 18:50:26.829 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration iphonedetect which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-10-11 18:50:26.834 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration naver_weather which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-10-11 18:50:26.838 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration xiaomi_cloud_map_extractor which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-10-11 18:50:26.843 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-10-11 18:50:36.628 WARNING (Recorder) [homeassistant.components.recorder.util] The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly
2024-10-11 18:50:36.889 WARNING (Recorder) [homeassistant.components.recorder.util] Ended unfinished session (id=11 from 2024-10-11 09:42:24.365616)
2024-10-11 18:50:57.675 WARNING (ImportExecutor_0) [homeassistant.components.camera] SUPPORT_ON_OFF was used from xiaomi_cloud_map_extractor, this is a deprecated constant which will be removed in HA Core 2025.1. Use CameraEntityFeature.ON_OFF instead, please report it to the author of the 'xiaomi_cloud_map_extractor' custom integration
2024-10-11 18:50:57.685 WARNING (ImportExecutor_0) [homeassistant.components.camera] SUPPORT_ON_OFF was used from xiaomi_cloud_map_extractor, this is a deprecated constant which will be removed in HA Core 2025.1. Use CameraEntityFeature.ON_OFF instead, please report it to the author of the 'xiaomi_cloud_map_extractor' custom integration
2024-10-11 18:50:57.835 WARNING (MainThread) [homeassistant.helpers.entity] Entity camera.xiaomi_cloud_map_extractor (<class 'custom_components.xiaomi_cloud_map_extractor.camera.VacuumCamera'>) is using deprecated supported features values which will be removed in HA Core 2025.1. Instead it should use <CameraEntityFeature.ON_OFF: 1>, please create a bug report at https://github.com/PiotrMachowski/Home-Assistant-custom-components-Xiaomi-Cloud-Map-Extractor/issues and reference https://developers.home-assistant.io/blog/2023/12/28/support-feature-magic-numbers-deprecation
2024-10-11 18:50:58.520 WARNING (SyncWorker_7) [homeassistant.helpers.frame] Detected that custom integration 'iphonedetect' accesses hass.helpers.event. This is deprecated and will stop working in Home Assistant 2024.11, it should be updated to import functions used from event directly at custom_components/iphonedetect/device_tracker.py, line 124: hass.helpers.event.track_point_in_utc_time(, please report it to the author of the 'iphonedetect' custom integration
2024-10-11 18:51:02.088 ERROR (SyncWorker_2) [homeassistant.components.xiaomi_miio.gateway] DeviceException during getting subdevices of xiaomi gateway with host 192.168.1.114, trying cloud to obtain subdevices: {'code': -5005, 'message': 'params error'}
2024-10-11 18:51:05.317 WARNING (SyncWorker_2) [miio.gateway.gateway] Unknown subdevice discovered, could not match zigbee_model 'lumi.magnet.agl02' of subdevice sid 'lumi.4cf8cdf3c80c13c' from Xiaomi gateway with ip: 192.168.1.114
2024-10-11 18:51:05.318 WARNING (SyncWorker_2) [miio.gateway.gateway] Unknown subdevice discovered, could not match zigbee_model 'lumi.switch.b2laus01' of subdevice sid 'lumi.54ef4410004baf57' from Xiaomi gateway with ip: 192.168.1.114
2024-10-11 18:51:05.319 WARNING (SyncWorker_2) [miio.gateway.gateway] Unknown subdevice discovered, could not match zigbee_model 'lumi.switch.b2laus01' of subdevice sid 'lumi.54ef4410004bb6bd' from Xiaomi gateway with ip: 192.168.1.114
2024-10-11 18:51:05.319 WARNING (SyncWorker_2) [miio.gateway.gateway] Unknown subdevice discovered, could not match zigbee_model 'lumi.switch.b2laus01' of subdevice sid 'lumi.54ef4410004bb809' from Xiaomi gateway with ip: 192.168.1.114
2024-10-11 18:51:06.441 ERROR (SyncWorker_5) [custom_components.xiaomi_cloud_map_extractor.camera] Failed to retrieve model
2024-10-11 18:51:07.838 WARNING (MainThread) [homeassistant.helpers.entity] Update of camera.xiaomi_cloud_map_extractor is taking over 10 seconds
2024-10-11 18:51:21.838 WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'naver_weather' calls async_forward_entry_setup for integration, naver_weather with title: 김포시 감정동 and entry_id: 6dd917080843473c10da71c2c1c309fb, which is deprecated and will stop working in Home Assistant 2025.6, await async_forward_entry_setups instead at custom_components/naver_weather/__init__.py, line 24: hass.async_create_task(, please report it to the author of the 'naver_weather' custom integration
2024-10-11 18:51:22.591 ERROR (MainThread) [homeassistant.components.hassio.handler] Client error on /ingress/validate_session request 401, message='Attempt to decode JSON with unexpected mimetype: text/plain; charset=utf-8', url='http://172.30.32.2/ingress/validate_session'
2024-10-11 18:51:22.592 ERROR (MainThread) [homeassistant.components.hassio] Failed to to call /ingress/validate_session - 
2024-10-11 18:51:26.897 ERROR (SyncWorker_5) [miio.miioprotocol] Got error when receiving: timed out
2024-10-11 18:51:26.901 WARNING (SyncWorker_5) [custom_components.xiaomi_cloud_map_extractor.camera] Got exception while fetching the state: No response from the device
2024-10-11 18:51:39.956 WARNING (MainThread) [homeassistant.helpers.frame] Detected code that calls async_forward_entry_setup for integration naver_weather with title: 김포시 감정동 and entry_id: 6dd917080843473c10da71c2c1c309fb, during setup without awaiting async_forward_entry_setup, which can cause the setup lock to be released before the setup is done. This will stop working in Home Assistant 2025.1. Please report this issue.
Stack (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2223, in async_forward_entry_setup
    _report_non_awaited_platform_forwards(entry, "async_forward_entry_setup")
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1192, in _report_non_awaited_platform_forwards
    report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 155, in report
    _LOGGER.warning(msg, stack_info=True)
2024-10-11 18:51:40.004 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: {('local_todo', 'e5297c9aee42fdcabdb01c0682741828'): 178.664171628, ('naver_weather', '6dd917080843473c10da71c2c1c309fb'): 197.112639659}
2024-10-11 18:51:47.176 ERROR (SyncWorker_5) [miio.miioprotocol] Got error when receiving: timed out
2024-10-11 18:51:49.959 WARNING (MainThread) [homeassistant.components.weather] Setup of weather platform naver_weather is taking over 10 seconds.
2024-10-11 18:51:49.994 WARNING (MainThread) [homeassistant.helpers.frame] Detected code that calls async_forward_entry_setup for integration naver_weather with title: 김포시 감정동 and entry_id: 6dd917080843473c10da71c2c1c309fb, during setup without awaiting async_forward_entry_setup, which can cause the setup lock to be released before the setup is done. This will stop working in Home Assistant 2025.1. Please report this issue.
Stack (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
    sys.exit(main())
  File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
    handle._run()
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2223, in async_forward_entry_setup
    _report_non_awaited_platform_forwards(entry, "async_forward_entry_setup")
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1192, in _report_non_awaited_platform_forwards
    report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 155, in report
    _LOGGER.warning(msg, stack_info=True)
2024-10-11 18:52:07.398 ERROR (SyncWorker_5) [miio.miioprotocol] Got error when receiving: timed out
2024-10-11 18:52:27.559 ERROR (SyncWorker_5) [miio.miioprotocol] Got error when receiving: timed out
2024-10-11 18:52:48.230 ERROR (SyncWorker_5) [miio.miioprotocol] Got error when receiving: timed out
2024-10-11 18:53:09.325 ERROR (SyncWorker_5) [miio.miioprotocol] Got error when receiving: timed out
2024-10-11 18:53:30.425 ERROR (SyncWorker_5) [miio.miioprotocol] Got error when receiving: timed out
2024-10-11 18:53:51.509 ERROR (SyncWorker_5) [miio.miioprotocol] Got error when receiving: timed out
2024-10-11 18:54:12.621 ERROR (SyncWorker_5) [miio.miioprotocol] Got error when receiving: timed out
2024-10-11 18:54:33.780 ERROR (SyncWorker_5) [miio.miioprotocol] Got error when receiving: timed out
2024-10-11 18:54:57.600 WARNING (MainThread) [homeassistant.components.media_player] Updating webostv media_player took longer than the scheduled update interval 0:00:10
2024-10-11 18:54:57.604 WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.tv is taking over 10 seconds

plz help me...!!!

mib1185 commented 5 days ago

To ensure, that not any custom component causes the issues, please restart HA in safe mode and check if the issue still occur, thx :+1:

hacscred commented 4 days ago

SQLite3 is not designed to be reliable for a long period of time. It's literally designed to last for the duration a cruise missile is in flight.

HAOS and the hardware you are running on is designed to be cheap, not perfect.

If you want reliability, buy a server with redundant storage and ECC memory (with remote access) and install Postgresql (or better).

It's unlikely that this is really a Home Assistant problem. The Home Assistant developers probably never shipped a product and as such underestimated the things that could go wrong.

Server hardware is extremely reliable.

cryptk commented 4 days ago

@hacscred Don't be so quick to be dismissive. I'm running home assistant on a proper server, and ever since the October release I have been experiencing a memory leak. I have rebooted home assistant in safe mode and the memory leak is still there.

I haven't opened an issue yet because I'm still working on gathering data to help the developers find the cause, but the symptom is that home assistant uses more and more RAM, eventually gets oom killed, and when it comes back up it logs an error about SQLite not being closed cleanly. This is almost certainly the cause of the issue in this ticket.

My symptoms are exactly the same, Home assistant will restart every 30 minutes to an hour, logging this error about the SQLite db (this error is expected when home assistant crashes or is killed, it's basically just informing you that the database was not closed cleanly, because it wasn't).

Restarting the entire system, or accessing it via its console and clearing out the used swap space, Will allow it to run for about a day with the amount of RAM that I'm giving the VM (6GB).

hacscred commented 3 days ago

@cryptk I said to run with Postgresql too, since nothing can be expected from SQLite. I know some people defend it online, but none of the people I respect that ever ran something serious use it in any production load.

I am not surprised SQLite isn't working, because I already knew that and basically implies that.

You are essentially just prolonging a broken design choice in Home Assistant by helping people with SQLite. Whoever decided that perhaps Postgresql should also be supported, should be given a medal of honor.

I know when the error happens, but there's always some excuse, which is why I recommend against it. It's not designed to run and run. Like I said, it's literally designed to last a few minutes and then terminate because of the surrounding explosion.

hacscred commented 3 days ago

Marking something off-topic? Who does that?

The solution to this problem is to remove SQLite support from Home Assistant. It was a mistake for it to have ever been added.

WladyTee commented 3 days ago

@ddong3000, I spent nearly 2 months with a continuous instability and multiple reboots. First I tried to clean all the database, but it didn't work. Then I decided to TEMPORARILY DISABLE all ADD-ONs. After that I went to CONFIGURATION.YAML and I put "#" on several sections to disable them.

ZHA: was giving a terrible issue, good detection of ZIGBEE CONBEE II, no good configuration. HTTP: created an issue with IP_AUTO_BAN. Other minor issues with TRACKER.

After that I had a fully disabled system: I tested the stability for a couple of days and then I began to ENABLE my personal options day after day.

I can only suggest you to begin on checking all existing settings because after 2024.09 we have a different HOME ASSISTANT core and there is no way to keep the same configuration: CONFIGURATION.YAML is not properly parsed and some settings now are generating strange conflicts. I experienced a lot of DNS issues, but I never found the reason of that. Now they disappeared.

So, spend sometime in checking your system with DISABLED options / add-ons / special settings / etc. My HOME ASSISTANT is fully working with backup 2024.07, but the continuous updates made my system unstable until I removed some old settings.

I hope it helps, good luck!

cryptk commented 3 days ago

@hacscred you are the one who is misunderstanding the issue here. SQLite is not broken, and the log line that OP reported is a WARNING, not an error. It is merely a warning saying that the database was not closed cleanly. Home Assistant and SQLite are 100% capable of recovering from this. The core of this issue is that the 2024.10 release of Home Assistant seems to have a memory leak somewhere which is causing the system to run out of ram and Home Assistant to be OOMKilled. When this happens, the database is obviously not closed cleanly, and when Home Assistant restarts, it logs a warning letting the user know.

SQLite is not broken here and switching to PSQL or MySQL will not fix this issue. While that change will make the warning go away, it won't fix the fact that there is a memory leak in the current version of Home Assistant and it gets OOMKilled every now and then because of it.

ddong3000 commented 3 days ago

Marking something off-topic? Who does that?

The solution to this problem is to remove SQLite support from Home Assistant. It was a mistake for it to have ever been added.

Some users who use home servers do not know what PostgreSQL is. And I don't even know how to use it. What I want to say is that Home Assistant fixes SQLite right away or updates an alternative that does not cause errors.

mib1185 commented 1 day ago

Did you already try to restart in safe mode as suggested in https://github.com/home-assistant/core/issues/128134#issuecomment-2407127823?

cogneato commented 1 day ago

What I want to say is that Home Assistant fixes SQLite right away or updates an alternative that does not cause errors.

You should view this message as an indication that your installation has crashed. The database was not shutdown nicely as it would with a normal restart or a reboot. It was instead abruptly ended. This message is informing you of this as it starts again.

What you instead want to find is the reason for your system repeatedly crashing. Using safe mode to rule out any custom integrations as suggested is a good start.

ddong3000 commented 1 day ago

Did you already try to restart in safe mode as suggested in #128134 (comment)?

yes. but not solved.

mib1185 commented 22 hours ago

if not already done, please setup the systemmonitor integration, so we get a first overview about the system resource usage of your HA instance. Further please restart in safe mode as mentioend above, wait until the unexpected restart occur again, than provide the complete homeassistant.log.1 (don't paste the content, but drag&drop the file to attache it as file)