@@ -63,6 +63,7 @@ import (
6363 "github.com/cortexproject/cortex/pkg/util/limiter"
6464 logutil "github.com/cortexproject/cortex/pkg/util/log"
6565 util_math "github.com/cortexproject/cortex/pkg/util/math"
66+ "github.com/cortexproject/cortex/pkg/util/requestmeta"
6667 "github.com/cortexproject/cortex/pkg/util/resource"
6768 "github.com/cortexproject/cortex/pkg/util/services"
6869 "github.com/cortexproject/cortex/pkg/util/spanlogger"
@@ -1696,7 +1697,7 @@ func (i *Ingester) QueryExemplars(ctx context.Context, req *client.ExemplarQuery
16961697 }
16971698
16981699 // We will report *this* request in the error too.
1699- c , err := i .trackInflightQueryRequest ()
1700+ c , err := i .trackInflightQueryRequest (ctx )
17001701 if err != nil {
17011702 return nil , err
17021703 }
@@ -1804,7 +1805,7 @@ func (i *Ingester) labelsValuesCommon(ctx context.Context, req *client.LabelValu
18041805 q .Close ()
18051806 }
18061807
1807- c , err := i .trackInflightQueryRequest ()
1808+ c , err := i .trackInflightQueryRequest (ctx )
18081809 if err != nil {
18091810 return nil , cleanup , err
18101811 }
@@ -1901,7 +1902,7 @@ func (i *Ingester) labelNamesCommon(ctx context.Context, req *client.LabelNamesR
19011902 q .Close ()
19021903 }
19031904
1904- c , err := i .trackInflightQueryRequest ()
1905+ c , err := i .trackInflightQueryRequest (ctx )
19051906 if err != nil {
19061907 return nil , cleanup , err
19071908 }
@@ -2252,7 +2253,7 @@ func (i *Ingester) QueryStream(req *client.QueryRequest, stream client.Ingester_
22522253 return nil
22532254}
22542255
2255- func (i * Ingester ) trackInflightQueryRequest () (func (), error ) {
2256+ func (i * Ingester ) trackInflightQueryRequest (ctx context. Context ) (func (), error ) {
22562257 gl := i .getInstanceLimits ()
22572258 if gl != nil && gl .MaxInflightQueryRequests > 0 {
22582259 if i .inflightQueryRequests .Load () >= gl .MaxInflightQueryRequests {
@@ -2262,7 +2263,7 @@ func (i *Ingester) trackInflightQueryRequest() (func(), error) {
22622263
22632264 i .maxInflightQueryRequests .Track (i .inflightQueryRequests .Inc ())
22642265
2265- if i .resourceBasedLimiter != nil {
2266+ if i .resourceBasedLimiter != nil && ! requestmeta . RequestFromRuler ( ctx ) {
22662267 if err := i .resourceBasedLimiter .AcceptNewRequest (); err != nil {
22672268 level .Warn (i .logger ).Log ("msg" , "failed to accept request" , "err" , err )
22682269 return nil , httpgrpc .Errorf (http .StatusServiceUnavailable , "failed to query: %s" , limiter .ErrResourceLimitReachedStr )
@@ -2282,7 +2283,7 @@ func (i *Ingester) queryStreamChunks(ctx context.Context, db *userTSDB, from, th
22822283 }
22832284 defer q .Close ()
22842285
2285- c , err := i .trackInflightQueryRequest ()
2286+ c , err := i .trackInflightQueryRequest (ctx )
22862287 if err != nil {
22872288 return 0 , 0 , 0 , 0 , err
22882289 }
0 commit comments