fix(blobnode): qos limit read io concurrence overload

@formatter:off

Signed-off-by: mawei029 <mawei2@oppo.com>
This commit is contained in:
mawei029 2025-08-28 16:35:53 +08:00 committed by slasher
parent 0ef70c8d48
commit b7c1606fa2
3 changed files with 9 additions and 5 deletions

View File

@ -36,6 +36,8 @@ type Qos interface {
Reader(context.Context, bnapi.IOType, io.Reader) io.Reader
TryAllow(rwType IOTypeRW) bool
Release(rwType IOTypeRW)
TryAcquireIO(ctx context.Context, chunkId uint64, rwType IOTypeRW) bool
ReleaseIO(chunkId uint64, rwType IOTypeRW)
ResetQosLimit(Config)
GetConfig() Config
Close()

View File

@ -415,11 +415,6 @@ func (cd *datafile) Read(ctx context.Context, shard *core.Shard, from, to uint32
return nil, bloberr.ErrInvalidParam
}
if !cd.qosAllow(ctx, qos.IOTypeRead) { // If there is too much io, it will discard some low-priority io
return nil, bloberr.ErrOverload
}
defer cd.qosRelease(qos.IOTypeRead)
// skip header
pos := shard.Offset + core.GetShardHeaderSize()

View File

@ -104,6 +104,13 @@ func (s *Service) ShardGet(c *rpc.Context) {
return
}
qosLmt := ds.GetIoQos()
if !qosLmt.TryAcquireIO(ctx, uint64(args.Vuid), qos.IOTypeRead) {
c.RespondError(bloberr.ErrOverload)
return
}
defer qosLmt.ReleaseIO(uint64(args.Vuid), qos.IOTypeRead)
// build shard reader
shard := core.NewShardReader(args.Bid, args.Vuid, from, to, w)