[homeassistant.setup] Setup of recorder is taking over 10 seconds

I just upgraded from 0.109.X, to 0.115.2, and hit this also:

sudo systemctl start home-assistant@homeassistant; ./hass-logs.sh
(snip)
Sep 20 15:13:06 hass systemd[1]: Started Home Assistant.
Sep 20 15:13:15 hass hass[14746]: 2020-09-20 15:13:15 WARNING (MainThread) [homeassistant.components.http] The 'base_url' option is deprecated, please remove it from your configuration
Sep 20 15:13:25 hass hass[14746]: 2020-09-20 15:13:25 WARNING (MainThread) [homeassistant.setup] Setup of recorder is taking over 10 seconds.


Sep 20 15:14:10 hass hass[14746]: 2020-09-20 15:14:10 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: recorder
Sep 20 15:15:10 hass hass[14746]: 2020-09-20 15:15:10 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: recorder
Sep 20 15:15:10 hass hass[14746]: 2020-09-20 15:15:10 WARNING (Recorder) [homeassistant.components.recorder.migration] Database is about to upgrade. Schema version: 7
Sep 20 15:15:10 hass hass[14746]: 2020-09-20 15:15:10 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding columns context_parent_id to table events. Note: this can take several minutes on large databases and slow computers. Please be patient!
Sep 20 15:15:10 hass hass[14746]: 2020-09-20 15:15:10 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding columns old_state_id to table states. Note: this can take several minutes on large databases and slow computers. Please be patient!
Sep 20 15:15:10 hass hass[14746]: 2020-09-20 15:15:10 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding index `ix_events_context_parent_id` to database. Note: this can take several minutes on large databases and slow computers. Please be patient!
Sep 20 15:16:12 hass hass[14746]: 2020-09-20 15:16:12 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: recorder
Sep 20 15:17:06 hass hass[14746]: 2020-09-20 15:17:06 WARNING (Recorder) [homeassistant.components.recorder.migration] Adding index `ix_events_event_type_time_fired` to database. Note: this can take several minutes on large databases and slow computers. Please be patient!
Sep 20 15:17:12 hass hass[14746]: 2020-09-20 15:17:12 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: recorder
Sep 20 15:18:12 hass hass[14746]: 2020-09-20 15:18:12 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: recorder
(homeassistant) homeassistant@hass:~/.homeassistant$ ls -ahl | grep db
-rw-r--r-- 1 homeassistant homeassistant 925M Sep 20 15:18 home-assistant_v2.db

I can confirm I/O on the system is pegged during this operation.

Subsequent logs are coming during startup but very very slow.
Eventually hass started (though the new system defaulting to only warning/error logs I wasn’t sure when it actually finished…)

Subsequent restarts STILL show

Sep 20 15:51:39 hass hass[16181]: 2020-09-20 15:51:39 WARNING (MainThread) [homeassistant.setup] Setup of recorder is taking over 10 seconds.
Sep 20 15:52:29 hass hass[16181]: 2020-09-20 15:52:29 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: recorder

...

So what is the expectation here? Are we supposed to be running some sort of DB prune periodically? Will this startup time take this long every time from now on? (!)

Try this…

hey @Sir_Goodenough ; thanks for the suggestion, while that may (likely?) resolve the performance issue - I’d argue that this might be a performance degradation … users shouldn’t have to setup anything other than sqlite IMO for a basic home install. Though if homeassistant has recommendations here for when is “too old” or “too large” to leave the default SQLite, then that’s a different story.

https://www.home-assistant.io/docs/backend/database/ doesn’t say anything beyond what is possible, and the options for users.

I have been seeing the same issue with mine. After a week I am being forced to delete the database. DOn’t care much of the history as I am saving all the information in InfluxDB for analytics. Would appreciate a more stable and hands-off solution to this.

I’m in the same position (don’t care much for the history) so Ive been limiting it to 2 days in my configuation.yaml file with:

recorder:
  purge_keep_days: 2
1 Like

Thanks darkly problem solved

When everyone is referring to restart is that restarting the system or HA service?
I’m running on docker and if I press restart server from HA it starts up straight away. If I stop it or reboot though it takes 10+ mins to start up. My db file is 3.8 Gb. I don’t understand what the difference between restarting and rebooting for HA.


, default is 10 days … so do we really have a problem of “2 vs. 10”?

I could see if the default were 30 or 60 … but it is 10, which isn’t that much history at all.

I had the same issue after a hard reboot of HA. What worked for me:

  • I stopped HA
  • I commented out recorder line in config
  • I started HA (it started normally)
  • I restored the recorder line in config
  • I restarted HA

That’s no recorder at all. OK if you never use history…
Might be better to be selective and save some of the stuff you may need, ignore others. That is also part of my video above.