Lxc copy --refresh -s otherpool does not work in some cases

lxc copy --refresh -s otherpool does not work, unless the original pool also exists on the destination? Or maybe it is something else that bothers it, don’t know, this is the only difference I could find between an instance where it works and the one where it doesn’t.

it correctly zfs receives the dataset in the corrrect pool but then bombs with “Volume already exists on storage but not in database”

time="2024-05-14T05:26:35Z" level=info msg="Migration receive stopped" instance=jira instanceType=container project=default
time="2024-05-14T05:26:35Z" level=error msg="Failed migration on target" clusterMoveSourceName= err="Failed creating instance on target: Volume already exists on storage but not in database" instance=jira live=false project=default push=fa
lse
time="2024-05-14T05:26:35Z" level=info msg="Migration channels disconnected on target" clusterMoveSourceName= instance=jira live=false project=default push=false
time="2024-05-14T05:26:35Z" level=debug msg="Instance operation lock finished" action=create err="Error transferring instance data: Failed migration on target: Failed creating instance on target: Volume already exists on storage but not in
 database" instance=jira project=default reusable=false
time="2024-05-14T05:26:35Z" level=debug msg="Removing device" device=scratch instance=jira instanceType=container project=default type=disk
time="2024-05-14T05:26:35Z" level=debug msg="Removing device" device=root instance=jira instanceType=container project=default type=disk
time="2024-05-14T05:26:35Z" level=debug msg="Removing device" device=eth0 instance=jira instanceType=container project=default type=nic
time="2024-05-14T05:26:35Z" level=info msg="ID: 47cb62ac-34be-4a34-a73c-d38f2e666dd6, Class: task, Description: Creating instance" CreatedAt="2024-05-14 05:26:35.104294458 +0000 UTC" Err="Error transferring instance data: Failed migration 
on target: Failed creating instance on target: Volume already exists on storage but not in database" Location=none MayCancel=false Metadata="map[]" Resources="map[containers:[/1.0/instances/jira] instances:[/1.0/instances/jira]]" Status=Fa
ilure StatusCode=Failure UpdatedAt="2024-05-14 05:26:35.104294458 +0000 UTC"
time="2024-05-14T05:26:35Z" level=debug msg="Failure for operation" class=task description="Creating instance" err="Error transferring instance data: Failed migration on target: Failed creating instance on target: Volume already exists on 
storage but not in database" operation=47cb62ac-34be-4a34-a73c-d38f2e666dd6 project=default
time="2024-05-14T05:26:35Z" level=debug msg="Event listener server handler stopped" listener=d8f7e427-2b27-4c57-a948-2f6ac0e689af local="172.18.6.4:8443" remote="192.168.221.182:49278"

lxd is 5.21.1-d46c406

Hi, could you please provide some reproducer steps? Does it fail if you run the copy operation with or without the -s option?

After spending several hours on this over the past days, I am officially lost :slight_smile:
it is very weird, it fails no matter what i specify -s mypool or - droot,pool=mypool or nothing

by pure chance I have managed to work around it by copying to an intermediate container on the same machine and then to destination, like this:

lxc copy --refresh ct ct-tmp
lxc copy --refresh ct-tmp destination:ct # this always succeeds

at this point i can lxc rm ct-tmp and continue what I actually wanted in the first place:

lxc copy --refresh ct destination:

there is one other workaround, failed initial copy --refresh leaves a zfs dataset which I can then import using lxd recover with minimal editing of backup.yaml and then continue --refreshing from there

all these containers have been created couple of years ago, if I create a fresh container, it always works, not sure what to look at, if you have a suggestion, would be very much appreciated

It maybe that the ZFS dataset layout on the source or target was invalid somehow for those older containers.

It would be useful to see an zfs list -t all for source and target for the container this occurs on.