Does Home Assistant Support Ubuntu 20?

I did a test install of Home Assistant using docker on an Ubuntu 18 VM just to make sure it was going to meet my needs. I’ve now moved over to my production server (4 core Xeon @ 3.1GHz, 32Gb of memory), and I can’t get Home Assistant to boot up cleanly. I’m getting constant “Setup of recorder is taking over 10 seconds” and “database is locked” errors, which I don’t understand. It’s a clean install, Home Assistant just created the database, so how has it managed to lock itself at the same time? If I let it sit for ~30 minutes it’ll eventually come online, but with errors about missing dependencies.

Server load is negligible, there are Grafana, InfluxDB Telegraf containers running, along with Portainer, but more than enough power for Home Assistant (I’m averaging 4% CPU load). My data volume is a NFS share on my Synology, but again this worked on Ubuntu 18, and that device only averages ~6% CPU load, so that shouldn’t be causing these database locks.

I followed exactly the same steps as I did on my Ubuntu 18 test VM, so the only variable is that this is Ubuntu 20. Any ideas?

The process I used is below…

Docker Setup

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo usermod -aG docker $USER
sudo systemctl enable docker

Docker Test
docker run hello-world runs without error without running as root.

NFS Volume Creation

docker volume create --driver local --opt type=nfs --opt o=addr=172.16.1.250,rw --opt device=:/volume1/DockerHost/home-assistant home_assistant

Home Assistant Container Creation

docker run --init -d --name="home-assistant" -e "TZ=America/New_York" -v home_assistant:/config -v /dev/ttyUSB0:/dev/ttyUSB0 --restart=always --net=host homeassistant/home-assistant:stable

Note that /dev/ttyUSB0 is my USB-Serial adapter connected to my whole home audio controller.

Also notable is that the NFS volume was empty. Creating the container did build the directory structure (.cloud, deps, home-assistant_v2.db, and the yaml files). I tried rebuilding it again this morning, and in the time it has taken me to write this post it still hasn’t come online yet (not accessible through the browser). home-assistant.log just contains the following, and there’s no real load on the system. It’s like it has hung but the logs don’t really give any inclination as to why.

2020-05-25 09:07:04 WARNING (MainThread) [homeassistant.setup] Setup of recorder is taking over 10 seconds.
2020-05-25 09:13:16 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 09:19:40 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 09:26:04 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 09:32:28 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)

I could rebuild the whole thing on Ubuntu 18, but that would mean rebuilding Grafana, InfluxDB and Telegraf so I’d consider that a last resort. I didn’t use the supervised install since I read the horror stories about upgrading when everything is broken out into different containers. Maybe someone can give me some suggestions as to what I’m doing wrong (or whether it’s purely related to Ubuntu 20).

You need docker-ce - which last I heard wasn’t available on 20.04.

Hmm, sudo apt-get install docker-ce docker-ce-cli containerd.io worked when I ran it… and the other containers are running… let me see if I can find anything specific about Docker on 20.04. I assumed if the other containers were up and running then it was working, but maybe there’s something missing that HA needs?

After almost an hour, it is now up, but dependency errors for recorder, history and logbook:

2020-05-25 09:07:04 WARNING (MainThread) [homeassistant.setup] Setup of recorder is taking over 10 seconds.
2020-05-25 09:13:16 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 09:19:40 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 09:26:04 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 09:32:28 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 09:38:52 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 09:45:16 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 09:51:40 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 09:58:04 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 10:04:28 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 10:10:52 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/e3q8) (retrying in 3 seconds)
2020-05-25 10:10:52 ERROR (MainThread) [homeassistant.setup] Setup failed for recorder: Integration failed to initialize.
2020-05-25 10:10:52 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of history. Setup failed for dependencies: recorder
2020-05-25 10:10:52 ERROR (MainThread) [homeassistant.setup] Setup failed for history: Could not set up all dependencies.
2020-05-25 10:10:52 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of logbook. Setup failed for dependencies: recorder
2020-05-25 10:10:52 ERROR (MainThread) [homeassistant.setup] Setup failed for logbook: Could not set up all dependencies.
2020-05-25 10:10:52 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of default_config. Setup failed for dependencies: history, logbook
2020-05-25 10:10:52 ERROR (MainThread) [homeassistant.setup] Setup failed for default_config: Could not set up all dependencies.

And I have confirmed that docker-ce is what’s running:

Client: Docker Engine - Community
 Version:           19.03.9
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        9d988398e7
 Built:             Fri May 15 00:25:20 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.9
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       9d988398e7
  Built:            Fri May 15 00:23:53 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

I dont’t think it has anything to do with Ubuntu 20.

Somehow your database file is locked. It is sqlite in your case, so it is just a file. I would look for that file and it’s permissions.

I think it should be save to delete the file if it is a new setup.

That’s the odd thing… I’ve completely deleted the db file a couple times, and it keeps doing the same thing. I would have assumed it’d just rebuild a fresh one that worked. It builds a new one, but still craps on itself. :sweat:

You’re not using Docker correctly if you have to rebuild everything. docker-compose up -d

As you are using docker, why not use a PostgreSQL database for Home Assistant. It should deliver a better performance anyway.
You have to configure recorder to use that instead of the SQLIite-DB.

If you still want to use the sqlite database: Where is the location of the DB? Is it inside the container itself? In a volume? It’s most likely a permission problem or something.

Turns out this was all caused by NFS locking. With correct NFS config it is now working.