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
[master] grow volumes if no writable volumes in current dataCenter (#5434)
Konstantin Lebedev9c1e0f5811c9
diff --git a/weed/operation/assign_file_id.go b/weed/operation/assign_file_id.goindex b6b870c3c9..1b7a0146db 100644--- a/weed/operation/assign_file_id.go+++ b/weed/operation/assign_file_id.go@@ -6,6 +6,7 @@ import ("github.com/seaweedfs/seaweedfs/weed/pb""github.com/seaweedfs/seaweedfs/weed/pb/master_pb""github.com/seaweedfs/seaweedfs/weed/security"+ "github.com/seaweedfs/seaweedfs/weed/stats""github.com/seaweedfs/seaweedfs/weed/storage/needle""google.golang.org/grpc""sync"@@ -193,6 +194,7 @@ func Assign(masterFn GetMasterFn, grpcDialOption grpc.DialOption, primaryRequest})if lastError != nil {+ stats.FilerHandlerCounter.WithLabelValues(stats.ErrorChunkAssign).Inc()continue}@@ -262,6 +264,7 @@ func (so *StorageOption) ToAssignRequests(count int) (ar *VolumeAssignRequest, aWritableVolumeCount: so.VolumeGrowthCount,}if so.DataCenter != "" || so.Rack != "" || so.DataNode != "" {+ ar.WritableVolumeCount = uint32(count)altRequest = &VolumeAssignRequest{Count: uint64(count),Replication: so.Replication,diff --git a/weed/stats/metrics_names.go b/weed/stats/metrics_names.goindex f97796e3bc..ffb0c76f17 100644--- a/weed/stats/metrics_names.go+++ b/weed/stats/metrics_names.go@@ -40,6 +40,7 @@ const (ErrorReadInternal = "read.internal.error"ErrorWriteEntry = "write.entry.failed"RepeatErrorUploadContent = "upload.content.repeat.failed"+ ErrorChunkAssign = "chunkAssign.failed"ErrorReadCache = "read.cache.failed"ErrorReadStream = "read.stream.failed")diff --git a/weed/topology/volume_growth_test.go b/weed/topology/volume_growth_test.goindex a3473c677f..04c5e8aeb2 100644--- a/weed/topology/volume_growth_test.go+++ b/weed/topology/volume_growth_test.go@@ -4,6 +4,7 @@ import ("encoding/json""fmt""github.com/seaweedfs/seaweedfs/weed/storage/types"+ "github.com/seaweedfs/seaweedfs/weed/util""testing""github.com/seaweedfs/seaweedfs/weed/sequence"@@ -419,11 +420,13 @@ func TestPickForWrite(t *testing.T) {Rack: "",DataNode: "",}+ v := util.GetViper()+ v.Set("master.volume_growth.threshold", 0.9)for _, rpStr := range []string{"001", "010", "100"} {rp, _ := super_block.NewReplicaPlacementFromString(rpStr)vl := topo.GetVolumeLayout("test", rp, needle.EMPTY_TTL, types.HardDriveType)volumeGrowOption.ReplicaPlacement = rp- for _, dc := range []string{"", "dc1", "dc2", "dc3"} {+ for _, dc := range []string{"", "dc1", "dc2", "dc3", "dc0"} {volumeGrowOption.DataCenter = dcfor _, r := range []string{""} {volumeGrowOption.Rack = r@@ -432,8 +435,13 @@ func TestPickForWrite(t *testing.T) {continue}volumeGrowOption.DataNode = dn- fileId, count, _, _, err := topo.PickForWrite(1, volumeGrowOption, vl)- if err != nil {+ fileId, count, _, shouldGrow, err := topo.PickForWrite(1, volumeGrowOption, vl)+ if dc == "dc0" {+ if err == nil || count != 0 || !shouldGrow {+ fmt.Println(dc, r, dn, "pick for write should be with error")+ t.Fail()+ }+ } else if err != nil {fmt.Println(dc, r, dn, "pick for write error :", err)t.Fail()} else if count == 0 {@@ -442,6 +450,9 @@ func TestPickForWrite(t *testing.T) {} else if len(fileId) == 0 {fmt.Println(dc, r, dn, "pick for write file id is empty")t.Fail()+ } else if shouldGrow {+ fmt.Println(dc, r, dn, "pick for write error : not should grow")+ t.Fail()}}}diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.goindex 516d6a9476..3c1c31aefc 100644--- a/weed/topology/volume_layout.go+++ b/weed/topology/volume_layout.go@@ -336,7 +336,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vireturn}}- return vid, count, locationList, shouldGrow, fmt.Errorf("No writable volumes in DataCenter:%v Rack:%v DataNode:%v", option.DataCenter, option.Rack, option.DataNode)+ return vid, count, locationList, true, fmt.Errorf("No writable volumes in DataCenter:%v Rack:%v DataNode:%v", option.DataCenter, option.Rack, option.DataNode)}func (vl *VolumeLayout) HasGrowRequest() bool {