diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2023-09-26 12:20:48 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-26 00:20:48 -0700 |
| commit | df4ded758e245bbef43bea86d09acdd717fc6b41 (patch) | |
| tree | 309875b2844228bb6cdbbaa262eb87c94edb79e8 | |
| parent | 19505c1cf44ce7c95032b3b007a200862a5c5c47 (diff) | |
| download | seaweedfs-df4ded758e245bbef43bea86d09acdd717fc6b41.tar.xz seaweedfs-df4ded758e245bbef43bea86d09acdd717fc6b41.zip | |
fix: avoid deleting more than one replica (#4873)
https://github.com/seaweedfs/seaweedfs/issues/4647
Co-authored-by: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.co>
| -rw-r--r-- | weed/shell/command_volume_fix_replication.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/weed/shell/command_volume_fix_replication.go b/weed/shell/command_volume_fix_replication.go index 56f5f5532..cee45ee1d 100644 --- a/weed/shell/command_volume_fix_replication.go +++ b/weed/shell/command_volume_fix_replication.go @@ -95,14 +95,15 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv, for vid, replicas := range volumeReplicas { replica := replicas[0] replicaPlacement, _ := super_block.NewReplicaPlacementFromByte(byte(replica.info.ReplicaPlacement)) - if replicaPlacement.GetCopyCount() > len(replicas) { + switch { + case replicaPlacement.GetCopyCount() > len(replicas): underReplicatedVolumeIds = append(underReplicatedVolumeIds, vid) - } else if replicaPlacement.GetCopyCount() < len(replicas) { + case isMisplaced(replicas, replicaPlacement): + misplacedVolumeIds = append(misplacedVolumeIds, vid) + fmt.Fprintf(writer, "volume %d replication %s is not well placed %+v\n", replica.info.Id, replicaPlacement, replica) + case replicaPlacement.GetCopyCount() < len(replicas): overReplicatedVolumeIds = append(overReplicatedVolumeIds, vid) fmt.Fprintf(writer, "volume %d replication %s, but over replicated %+d\n", replica.info.Id, replicaPlacement, len(replicas)) - } else if isMisplaced(replicas, replicaPlacement) { - misplacedVolumeIds = append(misplacedVolumeIds, vid) - fmt.Fprintf(writer, "volume %d replication %s is not well placed %+v\n", replica.info.Id, replicaPlacement, replicas) } } |
