Skip to content

Commit 5276dd1

Browse files
hczhu-dbyuchen-db
authored andcommitted
Add a command flag for lazyRetrievalMaxBufferedResponses in receive
1 parent aebf00d commit 5276dd1

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

cmd/thanos/receive.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,13 @@ func runReceive(
414414
return errors.Wrap(err, "setup gRPC server")
415415
}
416416

417+
if conf.lazyRetrievalMaxBufferedResponses <= 0 {
418+
return errors.New("--receive.lazy-retrieval-max-buffered-responses must be > 0")
419+
}
417420
options := []store.ProxyStoreOption{
418421
store.WithProxyStoreDebugLogging(debugLogging),
419422
store.WithoutDedup(),
423+
store.WithLazyRetrievalMaxBufferedResponsesForProxy(conf.lazyRetrievalMaxBufferedResponses),
420424
}
421425
if matcherConverter != nil {
422426
options = append(options, store.WithProxyStoreMatcherConverter(matcherConverter))
@@ -996,11 +1000,12 @@ type receiveConfig struct {
9961000

9971001
asyncForwardWorkerCount uint
9981002

999-
numTopMetricsPerTenant int
1000-
topMetricsMinimumCardinality uint64
1001-
topMetricsUpdateInterval time.Duration
1002-
matcherConverterCacheCapacity int
1003-
maxPendingGrpcWriteRequests int
1003+
numTopMetricsPerTenant int
1004+
topMetricsMinimumCardinality uint64
1005+
topMetricsUpdateInterval time.Duration
1006+
matcherConverterCacheCapacity int
1007+
maxPendingGrpcWriteRequests int
1008+
lazyRetrievalMaxBufferedResponses int
10041009

10051010
featureList *[]string
10061011
}
@@ -1170,6 +1175,8 @@ func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {
11701175
cmd.Flag("receive.max-pending-grcp-write-requests", "Reject right away gRPC write requests when this number of requests are pending. Value 0 disables this feature.").
11711176
Default("0").IntVar(&rc.maxPendingGrpcWriteRequests)
11721177
rc.featureList = cmd.Flag("enable-feature", "Comma separated experimental feature names to enable. The current list of features is "+metricNamesFilter+".").Default("").Strings()
1178+
cmd.Flag("receive.lazy-retrieval-max-buffered-responses", "The lazy retrieval strategy can buffer up to this number of responses. This is to limit the memory usage. This flag takes effect only when the lazy retrieval strategy is enabled.").
1179+
Default("20").IntVar(&rc.lazyRetrievalMaxBufferedResponses)
11731180
}
11741181

11751182
// determineMode returns the ReceiverMode that this receiver is configured to run in.

0 commit comments

Comments
 (0)