aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_volume_fix_replication.go
diff options
context:
space:
mode:
authorskycope <wings.wyang@gmail.com>2024-04-23 21:33:50 +0800
committerGitHub <noreply@github.com>2024-04-23 06:33:50 -0700
commit6e4b9181f5742b5a71c49ffb8f8e22ed0754ef5f (patch)
tree849a181e3ffb5f6e6cd910cd159ac6698c6a2adc /weed/shell/command_volume_fix_replication.go
parentcc2885b4f235c0de7ad2314b732cf4c52b531daf (diff)
downloadseaweedfs-6e4b9181f5742b5a71c49ffb8f8e22ed0754ef5f.tar.xz
seaweedfs-6e4b9181f5742b5a71c49ffb8f8e22ed0754ef5f.zip
fix "volume.fix.replication" move many replications only to one volumeServer (#5522)
Diffstat (limited to 'weed/shell/command_volume_fix_replication.go')
-rw-r--r--weed/shell/command_volume_fix_replication.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/weed/shell/command_volume_fix_replication.go b/weed/shell/command_volume_fix_replication.go
index b724f16f9..074931f40 100644
--- a/weed/shell/command_volume_fix_replication.go
+++ b/weed/shell/command_volume_fix_replication.go
@@ -4,16 +4,17 @@ import (
"context"
"flag"
"fmt"
+ "io"
+ "path/filepath"
+ "strconv"
+ "time"
+
"github.com/seaweedfs/seaweedfs/weed/pb"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
"github.com/seaweedfs/seaweedfs/weed/storage/needle_map"
"github.com/seaweedfs/seaweedfs/weed/storage/types"
"golang.org/x/exp/slices"
"google.golang.org/grpc"
- "io"
- "path/filepath"
- "strconv"
- "time"
"github.com/seaweedfs/seaweedfs/weed/operation"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
@@ -316,7 +317,7 @@ func (c *commandVolumeFixReplication) fixOneUnderReplicatedVolume(commandEnv *Co
if !takeAction {
// adjust volume count
- dst.dataNode.DiskInfos[replica.info.DiskType].VolumeCount++
+ addVolumeCount(dst.dataNode.DiskInfos[replica.info.DiskType], 1)
break
}
@@ -350,7 +351,7 @@ func (c *commandVolumeFixReplication) fixOneUnderReplicatedVolume(commandEnv *Co
}
// adjust volume count
- dst.dataNode.DiskInfos[replica.info.DiskType].VolumeCount++
+ addVolumeCount(dst.dataNode.DiskInfos[replica.info.DiskType], 1)
break
}
}
@@ -361,6 +362,14 @@ func (c *commandVolumeFixReplication) fixOneUnderReplicatedVolume(commandEnv *Co
return nil
}
+func addVolumeCount(info *master_pb.DiskInfo, count int) {
+ if info == nil {
+ return
+ }
+ info.VolumeCount += int64(count)
+ info.FreeVolumeCount -= int64(count)
+}
+
func keepDataNodesSorted(dataNodes []location, diskType types.DiskType) {
fn := capacityByFreeVolumeCount(diskType)
slices.SortFunc(dataNodes, func(a, b location) int {