mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-11-08 16:56:14 +08:00
fix "volume.fix.replication" move many replications only to one volumeServer (#5522)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user