SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
fix volume balance bug
Chris Lu55be09996d8f
diff --git a/weed/server/volume_grpc_copy.go b/weed/server/volume_grpc_copy.goindex 186c378efa..20778b71fe 100644--- a/weed/server/volume_grpc_copy.go+++ b/weed/server/volume_grpc_copy.go@@ -49,7 +49,7 @@ func (vs *VolumeServer) VolumeCopy(ctx context.Context, req *volume_server_pb.Voreturn fmt.Errorf("read volume file status failed, %v", err)}- volumeFileName = storage.VolumeFileName(volFileInfoResp.Collection, location.Directory, int(req.VolumeId))+ volumeFileName = storage.VolumeFileName(location.Directory, volFileInfoResp.Collection, int(req.VolumeId))// println("source:", volFileInfoResp.String())// copy ecx file@@ -63,6 +63,10 @@ func (vs *VolumeServer) VolumeCopy(ctx context.Context, req *volume_server_pb.Voreturn nil})++ idxFileName = volumeFileName + ".idx"+ datFileName = volumeFileName + ".dat"+if err != nil && volumeFileName != "" {if idxFileName != "" {os.Remove(idxFileName)@@ -117,11 +121,11 @@ todo: maybe should check the received count and deleted count of the volumefunc checkCopyFiles(originFileInf *volume_server_pb.ReadVolumeFileStatusResponse, idxFileName, datFileName string) error {stat, err := os.Stat(idxFileName)if err != nil {- return fmt.Errorf("get idx file info failed, %v", err)+ return fmt.Errorf("stat idx file %s failed, %v", idxFileName, err)}if originFileInf.IdxFileSize != uint64(stat.Size()) {- return fmt.Errorf("the idx file size [%v] is not same as origin file size [%v]",- stat.Size(), originFileInf.IdxFileSize)+ return fmt.Errorf("idx file %s size [%v] is not same as origin file size [%v]",+ idxFileName, stat.Size(), originFileInf.IdxFileSize)}stat, err = os.Stat(datFileName)diff --git a/weed/shell/command_volume_balance.go b/weed/shell/command_volume_balance.goindex f440dc5d2f..2a5731333b 100644--- a/weed/shell/command_volume_balance.go+++ b/weed/shell/command_volume_balance.go@@ -5,6 +5,7 @@ import ("flag""fmt""io"+ "math""os""sort""time"@@ -186,7 +187,7 @@ func balanceSelectedVolume(commandEnv *commandEnv, nodes []*Node, sortCandidatesselectedVolumeCount += len(dn.selectedVolumes)}- idealSelectedVolumes := selectedVolumeCount / len(nodes)+ idealSelectedVolumes := int(math.Ceil(float64(selectedVolumeCount) / float64(len(nodes))))hasMove := true