satellite/metabase/segmentloop: don't do rate limiting if disabled
We have a code to limit segments loop in case it will hit DB to hard but so far we didn't use this loop feature in production. This is a simple change to avoid logic responsible for rate limiting and its monitoring if limiting is disabled (RateLimit = 0) Change-Id: I43e07b407c6e65cf252303159d052eef250d1bea
This commit is contained in:
parent
142a04f208
commit
11d1e623b5
@ -438,10 +438,6 @@ func (loop *Service) iterateSegments(ctx context.Context, observers []*observerC
|
|||||||
|
|
||||||
rateLimiter := rate.NewLimiter(rate.Limit(loop.config.RateLimit), 1)
|
rateLimiter := rate.NewLimiter(rate.Limit(loop.config.RateLimit), 1)
|
||||||
|
|
||||||
if loop.config.RateLimit == 0 {
|
|
||||||
rateLimiter = rate.NewLimiter(rate.Inf, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
limit := loop.config.ListLimit
|
limit := loop.config.ListLimit
|
||||||
if limit <= 0 || limit > batchsizeLimit {
|
if limit <= 0 || limit > batchsizeLimit {
|
||||||
limit = batchsizeLimit
|
limit = batchsizeLimit
|
||||||
@ -474,15 +470,17 @@ func (loop *Service) iterateSegments(ctx context.Context, observers []*observerC
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
timer := mon.Timer("iterateLoopSegmentsRateLimit").Start()
|
if loop.config.RateLimit > 0 {
|
||||||
if err := rateLimiter.Wait(ctx); err != nil {
|
timer := mon.Timer("iterateLoopSegmentsRateLimit").Start()
|
||||||
// We don't really execute concurrent batches so we should never
|
if err := rateLimiter.Wait(ctx); err != nil {
|
||||||
// exceed the burst size of 1 and this should never happen.
|
// We don't really execute concurrent batches so we should never
|
||||||
// We can also enter here if the context is cancelled.
|
// exceed the burst size of 1 and this should never happen.
|
||||||
|
// We can also enter here if the context is cancelled.
|
||||||
|
timer.Stop()
|
||||||
|
return err
|
||||||
|
}
|
||||||
timer.Stop()
|
timer.Stop()
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
timer.Stop()
|
|
||||||
|
|
||||||
observers = withObservers(ctx, observers, func(ctx context.Context, observer *observerContext) bool {
|
observers = withObservers(ctx, observers, func(ctx context.Context, observer *observerContext) bool {
|
||||||
segment := Segment(entry)
|
segment := Segment(entry)
|
||||||
|
Loading…
Reference in New Issue
Block a user