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] avoid timeout when assigning for main request with filter by DC or rack (#6291)
Konstantin Lebedeve2e97db91764
diff --git a/weed/server/master_grpc_server_assign.go b/weed/server/master_grpc_server_assign.goindex a85045f7d3..4820de6a26 100644--- a/weed/server/master_grpc_server_assign.go+++ b/weed/server/master_grpc_server_assign.go@@ -5,6 +5,7 @@ import ("fmt""github.com/seaweedfs/seaweedfs/weed/glog""github.com/seaweedfs/seaweedfs/weed/stats"+ "strings""time""github.com/seaweedfs/raft"@@ -100,6 +101,9 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequestglog.V(1).Infof("assign %v %v: %v", req, option.String(), err)stats.MasterPickForWriteErrorCounter.Inc()lastErr = err+ if (req.DataCenter != "" || req.Rack != "") && strings.Contains(err.Error(), topology.NoWritableVolumes) {+ break+ }time.Sleep(200 * time.Millisecond)continue}diff --git a/weed/topology/topology.go b/weed/topology/topology.goindex be50eecdf9..8e55d33a99 100644--- a/weed/topology/topology.go+++ b/weed/topology/topology.go@@ -254,7 +254,7 @@ func (t *Topology) PickForWrite(requestedCount uint64, option *VolumeGrowOption,return "", 0, nil, shouldGrow, fmt.Errorf("failed to find writable volumes for collection:%s replication:%s ttl:%s error: %v", option.Collection, option.ReplicaPlacement.String(), option.Ttl.String(), err)}if volumeLocationList == nil || volumeLocationList.Length() == 0 {- return "", 0, nil, shouldGrow, fmt.Errorf("%s available for collection:%s replication:%s ttl:%s", noWritableVolumes, option.Collection, option.ReplicaPlacement.String(), option.Ttl.String())+ return "", 0, nil, shouldGrow, fmt.Errorf("%s available for collection:%s replication:%s ttl:%s", NoWritableVolumes, option.Collection, option.ReplicaPlacement.String(), option.Ttl.String())}nextFileId := t.Sequence.NextFileId(requestedCount)fileId = needle.NewFileId(vid, nextFileId, rand.Uint32()).String()diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.goindex 94493a1776..852798c19f 100644--- a/weed/topology/volume_layout.go+++ b/weed/topology/volume_layout.go@@ -31,7 +31,7 @@ const (readOnlyState volumeState = "ReadOnly"oversizedState = "Oversized"crowdedState = "Crowded"- noWritableVolumes = "No writable volumes"+ NoWritableVolumes = "No writable volumes")type stateIndicator func(copyState) bool@@ -302,7 +302,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vilenWriters := len(vl.writables)if lenWriters <= 0 {- return 0, 0, nil, true, fmt.Errorf("%s", noWritableVolumes)+ return 0, 0, nil, true, fmt.Errorf("%s", NoWritableVolumes)}if option.DataCenter == "" && option.Rack == "" && option.DataNode == "" {vid := vl.writables[rand.IntN(lenWriters)]@@ -337,7 +337,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vireturn}}- return vid, count, locationList, true, fmt.Errorf("%s in DataCenter:%v Rack:%v DataNode:%v", noWritableVolumes, option.DataCenter, option.Rack, option.DataNode)+ return vid, count, locationList, true, fmt.Errorf("%s in DataCenter:%v Rack:%v DataNode:%v", NoWritableVolumes, option.DataCenter, option.Rack, option.DataNode)}func (vl *VolumeLayout) HasGrowRequest() bool {