lib/storage: mention tag filters used in the query that led to error message

This should improve detecting invalid or heavy queries that lead to errors.
This commit is contained in:
Aliaksandr Valialkin 2020-08-10 13:36:00 +03:00
parent b3d4ff7ee2
commit f92255e803
2 changed files with 8 additions and 3 deletions

View File

@ -130,6 +130,9 @@ type Search struct {
ts tableSearch
// tfss contains tag filters used in the search.
tfss []*TagFilters
// deadline in unix timestamp seconds for the current search.
deadline uint64
@ -146,6 +149,7 @@ func (s *Search) reset() {
s.storage = nil
s.ts.reset()
s.tfss = nil
s.deadline = 0
s.err = nil
s.needClosing = false
@ -163,6 +167,7 @@ func (s *Search) Init(storage *Storage, tfss []*TagFilters, tr TimeRange, maxMet
}
s.reset()
s.tfss = tfss
s.deadline = deadline
s.needClosing = true
@ -195,10 +200,10 @@ func (s *Search) MustClose() {
// Error returns the last error from s.
func (s *Search) Error() error {
if s.err == io.EOF {
if s.err == io.EOF || s.err == nil {
return nil
}
return s.err
return fmt.Errorf("error when searching for tagFilters=%s: %w", s.tfss, s.err)
}
// NextMetricBlock proceeds to the next MetricBlockRef.

View File

@ -884,7 +884,7 @@ func (s *Storage) searchTSIDs(tfss []*TagFilters, tr TimeRange, maxMetrics int,
tsids, err := s.idb().searchTSIDs(tfss, tr, maxMetrics, deadline)
<-searchTSIDsConcurrencyCh
if err != nil {
return nil, fmt.Errorf("error when searching tsids for tfss %q: %w", tfss, err)
return nil, fmt.Errorf("error when searching tsids: %w", err)
}
return tsids, nil
}