From 279053572cb00ed0d7c357e2b087b20d9638cf38 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Mon, 16 May 2022 13:07:05 +0500 Subject: [PATCH 1/2] avoid delete volume replica if collection mismatch --- weed/shell/command_volume_fix_replication.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/weed/shell/command_volume_fix_replication.go b/weed/shell/command_volume_fix_replication.go index c4bef5925..b65d1996e 100644 --- a/weed/shell/command_volume_fix_replication.go +++ b/weed/shell/command_volume_fix_replication.go @@ -200,6 +200,13 @@ func (c *commandVolumeFixReplication) deleteOneVolume(commandEnv *CommandEnv, wr } } + for _, volumeReplica := range replicas { + if volumeReplica.info.Collection != replica.info.Collection { + fmt.Fprintf(writer, "skip delete volume %d as collection %s is mismatch: %s\n", replica.info.Id, replica.info.Collection, volumeReplica.info.Collection) + continue + } + } + fmt.Fprintf(writer, "deleting volume %d from %s ...\n", replica.info.Id, replica.location.dataNode.Id) if !takeAction { From 10d435f2c25658b16562adad975d81a71650b61d Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Mon, 16 May 2022 13:16:27 +0500 Subject: [PATCH 2/2] fix skip loop --- weed/shell/command_volume_fix_replication.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/weed/shell/command_volume_fix_replication.go b/weed/shell/command_volume_fix_replication.go index b65d1996e..3c5538550 100644 --- a/weed/shell/command_volume_fix_replication.go +++ b/weed/shell/command_volume_fix_replication.go @@ -200,12 +200,16 @@ func (c *commandVolumeFixReplication) deleteOneVolume(commandEnv *CommandEnv, wr } } + сollectionIsMismatch := false for _, volumeReplica := range replicas { if volumeReplica.info.Collection != replica.info.Collection { fmt.Fprintf(writer, "skip delete volume %d as collection %s is mismatch: %s\n", replica.info.Id, replica.info.Collection, volumeReplica.info.Collection) - continue + сollectionIsMismatch = true } } + if сollectionIsMismatch { + continue + } fmt.Fprintf(writer, "deleting volume %d from %s ...\n", replica.info.Id, replica.location.dataNode.Id)