Skip to content

Commit

Permalink
[Storage] Truncate search results to prevent OOM on jaeger-query.
Browse files Browse the repository at this point in the history
Signed-off-by: Annanay <[email protected]>
  • Loading branch information
Annanay committed Nov 20, 2018
1 parent 8a43417 commit 9eb7590
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions plugin/storage/cassandra/spanstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ func (s *SpanReader) FindTraces(ctx context.Context, traceQuery *spanstore.Trace
}
if traceQuery.NumTraces == 0 {
traceQuery.NumTraces = defaultNumTraces
} else if traceQuery.NumTraces > 10000 {
traceQuery.NumTraces = 10000
}

uniqueTraceIDs, err := s.findTraceIDs(ctx, traceQuery)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion plugin/storage/es/spanstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const (

defaultDocCount = 10000 // the default elasticsearch allowed limit
defaultNumTraces = 100
defaultNumSpans = 1000
)

var (
Expand Down Expand Up @@ -265,7 +266,7 @@ func (s *SpanReader) multiRead(ctx context.Context, traceIDs []string, startTime
if val, ok := searchAfterTime[traceID]; ok {
nextTime = val
}
searchRequests[i] = elastic.NewSearchRequest().IgnoreUnavailable(true).Type(spanType).Source(elastic.NewSearchSource().Query(query).Size(defaultDocCount).Sort("startTime", true).SearchAfter(nextTime))
searchRequests[i] = elastic.NewSearchRequest().IgnoreUnavailable(true).Type(spanType).Source(elastic.NewSearchSource().Query(query).Size(defaultDocCount).TerminateAfter(defaultNumSpans).Sort("startTime", true).SearchAfter(nextTime))
}
// set traceIDs to empty
traceIDs = nil
Expand Down

0 comments on commit 9eb7590

Please sign in to comment.