aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_volume_fix_replication.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2024-09-29 20:47:16 -0700
committerchrislu <chris.lu@gmail.com>2024-09-29 20:47:16 -0700
commit190b2fc27637017cdd075331fd04b8cb0e5879b7 (patch)
tree93db54c4ad83af2b09eb7862380b8c634154e203 /weed/shell/command_volume_fix_replication.go
parent8111ec13bd06e4a9142a87640986de8c41d4b75a (diff)
parent20929f2a5753a04385be2378e698c8df762b3256 (diff)
downloadseaweedfs-origin/mq2.tar.xz
seaweedfs-origin/mq2.zip
Merge branch 'master' into mq2origin/mq2
Diffstat (limited to 'weed/shell/command_volume_fix_replication.go')
-rw-r--r--weed/shell/command_volume_fix_replication.go27
1 files changed, 26 insertions, 1 deletions
diff --git a/weed/shell/command_volume_fix_replication.go b/weed/shell/command_volume_fix_replication.go
index 074931f40..2c35b3bcd 100644
--- a/weed/shell/command_volume_fix_replication.go
+++ b/weed/shell/command_volume_fix_replication.go
@@ -55,6 +55,10 @@ func (c *commandVolumeFixReplication) Help() string {
`
}
+func (c *commandVolumeFixReplication) HasTag(tag CommandTag) bool {
+ return false && tag == ResourceHeavy // resource intensive only when deleting and checking with replicas.
+}
+
func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
volFixReplicationCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
@@ -99,7 +103,7 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv,
replica := replicas[0]
replicaPlacement, _ := super_block.NewReplicaPlacementFromByte(byte(replica.info.ReplicaPlacement))
switch {
- case replicaPlacement.GetCopyCount() > len(replicas):
+ case replicaPlacement.GetCopyCount() > len(replicas) || !satisfyReplicaCurrentLocation(replicaPlacement, replicas):
underReplicatedVolumeIds = append(underReplicatedVolumeIds, vid)
case isMisplaced(replicas, replicaPlacement):
misplacedVolumeIds = append(misplacedVolumeIds, vid)
@@ -377,6 +381,27 @@ func keepDataNodesSorted(dataNodes []location, diskType types.DiskType) {
})
}
+func satisfyReplicaCurrentLocation(replicaPlacement *super_block.ReplicaPlacement, replicas []*VolumeReplica) bool {
+ existingDataCenters, existingRacks, _ := countReplicas(replicas)
+
+ if replicaPlacement.DiffDataCenterCount+1 > len(existingDataCenters) {
+ return false
+ }
+ if replicaPlacement.DiffRackCount+1 > len(existingRacks) {
+ return false
+ }
+ if replicaPlacement.SameRackCount > 0 {
+ foundSatisfyRack := false
+ for _, rackCount := range existingRacks {
+ if rackCount >= replicaPlacement.SameRackCount+1 {
+ foundSatisfyRack = true
+ }
+ }
+ return foundSatisfyRack
+ }
+ return true
+}
+
/*
if on an existing data node {
return false