Update: This statement is wrong. I initially checked the database via lxd SQL global .dump but this command is not showing the containers_config entries. If I open a copy of the database with sqlitebrowser I see I have entries for containers within containers_config, but the containers do not exist anymore.
It seems these entries are somehow not deleted during container deletion.
The initial error about /tmp/... is usually explained by your /tmp on the host having been partly wiped, specifically the directory that’s exposed to LXD as it’s /tmp in the snap.
There isn’t really any good way to repair that kind of breakage on a running system, your best luck would be to reboot the system.
Specifically what was deleted from the host is a directory called /tmp/snap.0_lxd_XXXXXXX which is mapped to /tmp in the snap’s mount namespace. The no such file or directory error comes as a result of /tmp itself being invalid.
Thanks for the hint with the temp-file. On the build-nodes was tmpreaper installed.
After adding /tmp/snap.* to TMPREAPER_PROTECT_EXTRA the error was gone.
Regarding the database: I had 3.0.x installed on the build nodes and upgraded to 3.7. After the upgrade, the occasional database issues seem to be gone.