@@ -301,13 +301,8 @@ func (u *BucketStores) Series(req *storepb.SeriesRequest, srv storepb.Store_Seri
301
301
defer spanLog .Span .Finish ()
302
302
303
303
maxInflightRequests := u .cfg .BucketStore .MaxInflightRequests
304
- if maxInflightRequests > 0 {
305
- if u .inflightRequestCnt >= maxInflightRequests {
306
- return ErrTooManyInflightRequests
307
- }
308
-
309
- u .incrementInflightRequestCnt ()
310
- defer u .decrementInflightRequestCnt ()
304
+ if maxInflightRequests > 0 && u .getInflightRequestCnt () >= maxInflightRequests {
305
+ return ErrTooManyInflightRequests
311
306
}
312
307
313
308
userID := getUserIDFromGRPCContext (spanCtx )
@@ -330,6 +325,11 @@ func (u *BucketStores) Series(req *storepb.SeriesRequest, srv storepb.Store_Seri
330
325
return nil
331
326
}
332
327
328
+ if maxInflightRequests > 0 {
329
+ u .incrementInflightRequestCnt ()
330
+ defer u .decrementInflightRequestCnt ()
331
+ }
332
+
333
333
err = store .Series (req , spanSeriesServer {
334
334
Store_SeriesServer : srv ,
335
335
ctx : spanCtx ,
@@ -338,6 +338,12 @@ func (u *BucketStores) Series(req *storepb.SeriesRequest, srv storepb.Store_Seri
338
338
return err
339
339
}
340
340
341
+ func (u * BucketStores ) getInflightRequestCnt () int {
342
+ u .inflightRequestMu .RLock ()
343
+ defer u .inflightRequestMu .RUnlock ()
344
+ return u .inflightRequestCnt
345
+ }
346
+
341
347
func (u * BucketStores ) incrementInflightRequestCnt () {
342
348
u .inflightRequestMu .Lock ()
343
349
u .inflightRequestCnt ++
0 commit comments