forked from TrueCloudLab/frostfs-node
[#1677] writecache: Add QoS limiter usage
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
7893d763d1
commit
07a660fbc4
5 changed files with 27 additions and 1 deletions
|
@ -67,7 +67,13 @@ func (c *cache) pushToFlushQueue(ctx context.Context, fl *flushLimiter) {
|
|||
continue
|
||||
}
|
||||
|
||||
err := c.fsTree.IterateInfo(ctx, func(oi fstree.ObjectInfo) error {
|
||||
release, err := c.qosLimiter.ReadRequest(ctx)
|
||||
if err != nil {
|
||||
c.log.Warn(ctx, logs.WriteCacheFailedToAcquireRPSQuota, zap.String("operation", "fstree.IterateInfo"), zap.Error(err))
|
||||
c.modeMtx.RUnlock()
|
||||
continue
|
||||
}
|
||||
err = c.fsTree.IterateInfo(ctx, func(oi fstree.ObjectInfo) error {
|
||||
if err := fl.acquire(oi.DataSize); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -82,6 +88,7 @@ func (c *cache) pushToFlushQueue(ctx context.Context, fl *flushLimiter) {
|
|||
return ctx.Err()
|
||||
}
|
||||
})
|
||||
release()
|
||||
if err != nil {
|
||||
c.log.Warn(ctx, logs.BlobstorErrorOccurredDuringTheIteration, zap.Error(err))
|
||||
}
|
||||
|
@ -113,6 +120,12 @@ func (c *cache) workerFlush(ctx context.Context, fl *flushLimiter) {
|
|||
func (c *cache) flushIfAnObjectExistsWorker(ctx context.Context, objInfo objectInfo, fl *flushLimiter) {
|
||||
defer fl.release(objInfo.size)
|
||||
|
||||
release, err := c.qosLimiter.WriteRequest(ctx)
|
||||
if err != nil {
|
||||
c.log.Warn(ctx, logs.WriteCacheFailedToAcquireRPSQuota, zap.String("operation", "fstree.Get"), zap.Error(err))
|
||||
return
|
||||
}
|
||||
defer release()
|
||||
res, err := c.fsTree.Get(ctx, common.GetPrm{
|
||||
Address: objInfo.addr,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue