mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
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>
This commit is contained in:
parent
19505c1cf4
commit
df4ded758e
|
@ -95,14 +95,15 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv,
|
||||||
for vid, replicas := range volumeReplicas {
|
for vid, replicas := range volumeReplicas {
|
||||||
replica := replicas[0]
|
replica := replicas[0]
|
||||||
replicaPlacement, _ := super_block.NewReplicaPlacementFromByte(byte(replica.info.ReplicaPlacement))
|
replicaPlacement, _ := super_block.NewReplicaPlacementFromByte(byte(replica.info.ReplicaPlacement))
|
||||||
if replicaPlacement.GetCopyCount() > len(replicas) {
|
switch {
|
||||||
|
case replicaPlacement.GetCopyCount() > len(replicas):
|
||||||
underReplicatedVolumeIds = append(underReplicatedVolumeIds, vid)
|
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)
|
overReplicatedVolumeIds = append(overReplicatedVolumeIds, vid)
|
||||||
fmt.Fprintf(writer, "volume %d replication %s, but over replicated %+d\n", replica.info.Id, replicaPlacement, len(replicas))
|
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue