Is my Home Asssistant dead ? :(

Hello all,

I think I waited too long before upgrading my Haasio 0.113 to 0.116.0 (as well as the supervisor).
After having upgraded both supervisor and haasio, I started to have some issues with some custom components (like garbage_collection which was manually installed). I also saw issues related to the “entity_id” that are now depreciated.

I tried to update manually my few custom components and then launch the “configuration check” tool from the UI. It runs endlessly and I get no results, so I can’t restart Hassio.

Now I think I’m losing my installation completely :frowning: There are more and more errors in the log as you can see below with sqlite3 integrity errors. As a consequence, I have no more historical data for my sensors, as an exemple.
I’m completely lost and don’t know what to do to “re-take” some control of my installation… :frowning: Any advice please ? (and sorry for my bad english level).

Delete your home-assistant_v2.db and restart. You will lose your saved history.

I think you should just remove the custom components directory and the DB file (home-assistant_v2.db), and see if that fixes it. If it doesn’t, the easiest thing would be to create and download a snapshot. Create a fresh install, then untar the snapshot and find the configuration, and copy everything but the custom_components folder.

I cannot restart from the UI, nothing happens. Should I perform an hard reboot of my Raspberry ? Won’t that make things worse?

No, it shouldn’t make anything worse to do a hard reboot. Remove the SD card and plug it into a linux-supporting system, copy out your configuration on to your computer, and then try a fresh reinstall. Then copy out your configuration onto the new reinstall (except the DB and custom components).
And don’t worry. Even if it feels like the world is falling apart, you’re going to be just fine in the end.

Ok, thanks @KTibow ! I’m doing that. And keep my fingers crossed.

Can you post the first error in the log related to the recorder. Its likely the cause and the rest if what happened once that occurred.

0.116.1 and later should recover on this type of error if there is not corruption in the sqlite database.

So… I started by backuping everything and I deleted the DB file “home-assistant_v2.db” before an hard reboot of my Raspberry… and it seems OK now ! Sometimes the hard restart seems to be the only true solution :smiley:

I then upgraded my custom components (garbage_collection and unifi_protect). It seems I still have some issues with scripts content (maybe the use of the entity_id).

@bdraco, I’ve searched in a backup of my logs and here is the first time I see errors related to the recorder :

2020-10-08 23:51:10 ERROR (MainThread) [homeassistant.components.mobile_app.notify] Requested entity was not found. This message is generated externally to Home Assistant.
2020-10-09 00:04:13 ERROR (SyncWorker_62) [spotipy.client] HTTP Error for GET to https://api.spotify.com/v1/me/player/devices returned 401 due to The access token expired
2020-10-09 03:54:25 WARNING (MainThread) [homeassistant.helpers.entity] Update of vacuum.nestor is taking over 10 seconds
2020-10-09 03:54:25 WARNING (SyncWorker_35) [homeassistant.components.xiaomi_miio.vacuum] Got exception while fetching the state: Unable to discover the device 192.168.107.15
2020-10-09 03:54:45 WARNING (MainThread) [homeassistant.helpers.entity] Update of vacuum.nestor is taking over 10 seconds
2020-10-09 04:12:01 ERROR (Recorder) [homeassistant.components.recorder] Error executing query: Instance <States at 0x6a5514c0> is not present in this Session
2020-10-09 04:12:01 ERROR (Recorder) [homeassistant.components.recorder] Error saving events: Instance <States at 0x6a5514c0> is not present in this Session
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 442, in _commit_event_session_or_retry
    self._commit_event_session()
  File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 497, in _commit_event_session
    self.event_session.expunge(dbstate)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 1854, in expunge
    raise sa_exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Instance <States at 0x6a5514c0> is not present in this Session
2020-10-09 04:12:02 ERROR (Recorder) [homeassistant.components.recorder] Error executing query: Instance <States at 0x6a5514c0> is not present in this Session
2020-10-09 04:12:02 ERROR (Recorder) [homeassistant.components.recorder] Error saving events: Instance <States at 0x6a5514c0> is not present in this Session
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 442, in _commit_event_session_or_retry
    self._commit_event_session()
  File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 497, in _commit_event_session
    self.event_session.expunge(dbstate)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 1854, in expunge
    raise sa_exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Instance <States at 0x6a5514c0> is not present in this Session
2020-10-09 04:12:03 ERROR (Recorder) [homeassistant.components.recorder] Error executing query: Instance <States at 0x6a5514c0> is not present in this Session
2020-10-09 04:12:03 ERROR (Recorder) [homeassistant.components.recorder] Error saving events: Instance <States at 0x6a5514c0> is not present in this Session
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 442, in _commit_event_session_or_retry
    self._commit_event_session()
  File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 497, in _commit_event_session
    self.event_session.expunge(dbstate)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 1854, in expunge
    raise sa_exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Instance <States at 0x6a5514c0> is not present in this Session
2020-10-09 04:12:04 ERROR (Recorder) [homeassistant.components.recorder] Error executing query: Instance <States at 0x6a5514c0> is not present in this Session
2020-10-09 04:12:04 ERROR (Recorder) [homeassistant.components.recorder] Error saving events: Instance <States at 0x6a5514c0> is not present in this Session

It looks like the database purge happened to delete the state that was about to be expunged. That shouldn’t be possible anymore with 0.116.1

What happened to home assistant being able to recognise a corrupt db and generating a new one?

It can only do that if it corruption is bad enough that we can detect it at startup with the light checks we do. We could do a more exhaustive check but it would mean startup would take a few minutes.

1 Like

Thank you all for the explainations on what happened. I’ve upgraded to 0.116.2, so I should be on the safe side now :slight_smile:

Are you using HACS for your custom components? It makes integrating things like Garbage collection much easier.

1 Like

You are right @mattyman and it’s now done, HACS has been installed and configured. I think I now have to “re-install” all the custom components through HACS so they will be known and managed.

1 Like