diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2024-11-26 21:33:31 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-26 08:33:31 -0800 |
| commit | e2e97db917641769b5ddf6c311c406ec63463a10 (patch) | |
| tree | c1f89cb0c8d773cc483073e31d617728c73b0172 | |
| parent | fec88e64eb7c33e73b2e6da2afa99d68db56e495 (diff) | |
| download | seaweedfs-e2e97db917641769b5ddf6c311c406ec63463a10.tar.xz seaweedfs-e2e97db917641769b5ddf6c311c406ec63463a10.zip | |
[master] avoid timeout when assigning for main request with filter by DC or rack (#6291)
* avoid timeout when assigning for main request with filter by DC or rack
https://github.com/seaweedfs/seaweedfs/issues/6290
* use constant NoWritableVolumes
| -rw-r--r-- | weed/server/master_grpc_server_assign.go | 4 | ||||
| -rw-r--r-- | weed/topology/topology.go | 2 | ||||
| -rw-r--r-- | weed/topology/volume_layout.go | 6 |
3 files changed, 8 insertions, 4 deletions
diff --git a/weed/server/master_grpc_server_assign.go b/weed/server/master_grpc_server_assign.go index a85045f7d..4820de6a2 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.AssignRequest glog.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.go index be50eecdf..8e55d33a9 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.go index 94493a177..852798c19 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) (vi lenWriters := 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) (vi return } } - 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 { |
