LXD not starting after version update

I’m sorry if this is a duplicate question, but I am not able to solve it myself…

I am running Arch with LXD and after an uptime of about 2 months recently updated all packages, including LXD (now 4.6, I don’t know which version I had before that). Ever since the update, all lxc related commands result in an endless wait time and nothing works.

According to some thread I found, I stopped all lxd related processes, then started it with lxd --debug. The output is attached below:

~ lxd --debug
INFO[10-07|13:55:46] LXD 4.6 is starting in normal mode path=/var/lib/lxd
INFO[10-07|13:55:46] Kernel uid/gid map:
INFO[10-07|13:55:46] - u 0 0 4294967295
INFO[10-07|13:55:46] - g 0 0 4294967295
INFO[10-07|13:55:46] Configured LXD uid/gid map:
INFO[10-07|13:55:46] - u 0 1000000 65536
INFO[10-07|13:55:46] - g 0 1000000 65536
INFO[10-07|13:55:46] Kernel features:
INFO[10-07|13:55:46] - closing multiple file descriptors efficiently: no
INFO[10-07|13:55:46] - netnsid-based network retrieval: yes
INFO[10-07|13:55:46] - pidfds: yes
INFO[10-07|13:55:46] - uevent injection: yes
INFO[10-07|13:55:46] - seccomp listener: yes
INFO[10-07|13:55:46] - seccomp listener continue syscalls: yes
INFO[10-07|13:55:46] - seccomp listener add file descriptors: no
INFO[10-07|13:55:46] - attach to namespaces via pidfds: yes
INFO[10-07|13:55:46] - safe native terminal allocation : no
INFO[10-07|13:55:46] - unprivileged file capabilities: yes
INFO[10-07|13:55:46] - cgroup layout: hybrid
WARN[10-07|13:55:46] - Couldn’t find the CGroup blkio.weight, I/O weight limits will be ignored
INFO[10-07|13:55:46] - shiftfs support: no
INFO[10-07|13:55:46] Initializing local database
DBUG[10-07|13:55:46] Initializing database gateway
DBUG[10-07|13:55:46] Start database node address= role=voter id=1
INFO[10-07|13:55:47] Starting /dev/lxd handler:
INFO[10-07|13:55:47] - binding devlxd socket socket=/var/lib/lxd/devlxd/sock
INFO[10-07|13:55:47] REST API daemon:
INFO[10-07|13:55:47] - binding Unix socket socket=/var/lib/lxd/unix.socket
INFO[10-07|13:55:47] Initializing global database
DBUG[10-07|13:55:47] Dqlite: attempt 0: server 1: connected
INFO[10-07|13:55:48] Updating the LXD global schema. Backup made as “global.bak”
DBUG[10-07|13:55:49] Updating global DB schema from 33 to 34
DBUG[10-07|13:55:49] Updating global DB schema from 34 to 35
DBUG[10-07|13:55:49] Database error: &errors.errorString{s:“failed to apply update 34: invalid ID”}
EROR[10-07|13:55:49] Failed to start the daemon: failed to open cluster database: failed to ensure schema: failed to apply update 34: invalid ID
INFO[10-07|13:55:49] Starting shutdown sequence
INFO[10-07|13:55:49] Stop database gateway
INFO[10-07|13:55:49] Stopping REST API handler:
INFO[10-07|13:55:49] - closing socket socket=/var/lib/lxd/unix.socket
INFO[10-07|13:55:49] Stopping /dev/lxd handler:
INFO[10-07|13:55:49] - closing socket socket=/var/lib/lxd/devlxd/sock
DBUG[10-07|13:55:49] Not unmounting temporary filesystems (containers are still running)
Error: failed to open cluster database: failed to ensure schema: failed to apply update 34: invalid ID

Now, my research has led me here: https://github.com/lxc/lxd/issues/7920

You can see if there’s something wrong by running SELECT * FROM storage_volumes_snapshots WHERE id IN (SELECT id FROM storage_volumes);

So, that’s what I tried next:

~ lxd sql -d global “SELECT * FROM storage_volumes_snapshots WHERE id IN (SELECT id FROM storage_volumes);”
DBUG[10-07|14:00:09] Connecting to a local LXD over a Unix socket
DBUG[10-07|14:00:09] Sending request to LXD method=POST url=http://unix.socket/internal/sql etag=
“database”: “global”,
“query”: “SELECT * FROM storage_volumes_snapshots WHERE id IN (SELECT id FROM storage_volumes);”
Error: Post “http://unix.socket/internal/sql”: EOF

Now I reached a point where I do not know how I can proceed. I guess there’s either something wrong with my socket or DB, but have no experience with either, so I’m at a dead end here.

Since this is only a private environment (homeserver for various applications) I’m not in a huge hurry, but I would be glad if someone can help me, or even just point me into the right direction.

If you need any other logs in order to help, just tell me what I have to do!

Kind regards,

Use sqlite3 /var/snap/lxd/common/lxd/database/global/db.bin to run that SELECT, then write the patch.global.sql file and start LXD again.

lxd sql global requires LXD to be running, the sqlite3 command lets you see the last state of the DB, note that changes done through it will not persist (that’s why we’re using the patch file for writes).

1 Like

Thank you very much - that fixed it.

I should have thought that lxd sql required lxd to be running…
All my containers booted up like a charm.

Excellent, sorry for the bumpiness.