Request for help : UNIQUE constraint failed: storage_volumes_snapshots.id

We use lxd version 3.22 on an ubuntu 18.04 server.
After creating a container, using lxc launch ubuntu:18.04 c2
If we give lxc snapshot c2, we get the error
Error: Create instance: Insert volume snapshot: UNIQUE constraint failed: storage_volumes_snapshots.id
lxc ls | grep c2
| c2 | RUNNING | | | CONTAINER | 0 |

lxc profile show default
config: {}
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: bridged
parent: br0
type: nic
root:
path: /
pool: default
type: disk
name: default
used_by:

  • /1.0/instances/c1
  • /1.0/instances/c2

zpool list
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
default 34.8T 136G 34.6T - 0% 0% 1.00x ONLINE -

lxc info c2
Name: c2
Location: none
Remote: unix://
Architecture: x86_64
Created: 2020/03/16 09:40 UTC
Status: Running
Type: container
Profiles: default
Pid: 52380
Ips:
eth0: inet6 fe80::216:3eff:fe81:b41b veth8b9a0c19
lo: inet 127.0.0.1
lo: inet6 ::1
Resources:
Processes: 42
Disk usage:
root: 11.46MB
CPU usage:
CPU usage (in seconds): 7
Memory usage:
Memory (current): 175.35MB
Network usage:
eth0:
Bytes received: 314.06kB
Bytes sent: 3.37kB
Packets received: 1672
Packets sent: 17
lo:
Bytes received: 3.78kB
Bytes sent: 3.78kB
Packets received: 52
Packets sent: 52

snap list
Name Version Rev Tracking Publisher Notes
core 16-2.43.3 8689 stable canonical✓ core
lxd 3.22 13717 stable canonical✓ -

Could anyone help, please ?
Thanks in advance.
–Mohanan PG , NITK Surathkal, India

@freeekanayaka another one of those

I can’t reproduce this on a fresh LXD deployment. We’ll see if we get a follow-up from https://github.com/lxc/lxd/issues/7024.

I would like to clarify that our installation was upgraded to 3.22 through (an automatic) snap refresh in the background. We started with an earlier version. It was working well (through cron jobs) so far.
We have 5 identical servers. In four of them after an apt full-upgrade and a system restart, the snapshots are working well. Not on this one. We couldn’t figure out why.
Hence the query.
Thanks and Regards. MohananPG

Resolved!
Thanks for the tip from https://github.com/lxc/lxd/issues/7024 : Post from James Fraser (fwaggle).
I did the following.
lxd sql global “SELECT MAX(id) FROM storage_volumes_all LIMIT 1;”
±--------+
| MAX(id) |
±--------+
| 125 |
±--------+
lxd sql global “UPDATE sqlite_sequence SET seq = 125 WHERE name = ‘storage_volumes’”
Rows affected: 1
Now lxc snapshot c2 works

lxc info c2
Name: c2
Location: none
Remote: unix://
Architecture: x86_64
Created: 2020/03/16 09:40 UTC
Status: Running
Type: container
Profiles: default
Pid: 21647

Snapshots:
snap0 (taken at 2020/03/17 04:17 UTC) (stateless)
Thanks once again.
Best regards
Stay safe.
–mohananpg, india