Database error: "sql: transaction has already been committed or rolled back"

You could remove the snapshot records from the database manually using:

lxd sql global 'select instances.name as instance_name, instances_snapshots.id as snapshot_id, instances_snapshots.name as snapshot_name from instances_snapshots join instances on instances.id = instances_snapshots.instance_id order by instance_name, snapshot_id'
+---------------+-------------+---------------+
| instance_name | snapshot_id | snapshot_name |
+---------------+-------------+---------------+
| c1            | 415         | snap0         |
| c1            | 416         | snap1         |
| c1            | 417         | snap2         |
| c1            | 418         | snap3         |
| c1            | 419         | snap4         |
| c1            | 420         | snap5         |
| c1            | 421         | snap6         |
| c1            | 422         | snap7         |
| c1            | 423         | snap8         |
| c1            | 424         | snap9         |
| c1            | 425         | snap10        |
+---------------+-------------+---------------+

and for the associated storage volume snapshot records:

lxd sql global 'select storage_volumes.name as instance_name, storage_volumes_snapshots.id as instance_volume_snapshot_id, storage_volumes_snapshots.name as snapshot_name from storage_volumes_snapshots join storage_volumes on storage_volumes.id = storage_volumes_snapshots.storage_volume_id where storage_volumes.type = 0 order by instance_name, instance_volume_snapshot_id'
+---------------+-----------------------------+-----------------+
| instance_name | instance_volume_snapshot_id | snapshot_name |
+---------------+-----------------------------+---------------+
| c1            | 9472                        | snap0         |
| c1            | 9473                        | snap1         |
| c1            | 9474                        | snap2         |
| c1            | 9475                        | snap3         |
| c1            | 9476                        | snap4         |
| c1            | 9477                        | snap5         |
| c1            | 9478                        | snap6         |
| c1            | 9479                        | snap7         |
| c1            | 9480                        | snap8         |
| c1            | 9481                        | snap9         |
| c1            | 9482                        | snap10        |
+---------------+-----------------------------+---------------+

Identifying the rows you can remove and then doing:

lxd sql global 'delete from instances_snapshots where id = <snapshot_id>'
lxd sql global 'delete from storage_volumes_snapshots where id = <instance_volume_snapshot_id>'
1 Like