lib/storage: pass missing AccountID and ProjectID to searchMetricName

This commit is contained in:
Aliaksandr Valialkin 2020-01-30 15:14:59 +02:00
parent 4ed5e9a7ce
commit 1332ddc15e

View file

@ -716,6 +716,7 @@ func (s *Storage) searchTSIDs(tfss []*TagFilters, tr TimeRange, maxMetrics int)
// This should speed-up further searchMetricName calls for metricIDs from tsids. // This should speed-up further searchMetricName calls for metricIDs from tsids.
func (s *Storage) prefetchMetricNames(tsids []TSID) error { func (s *Storage) prefetchMetricNames(tsids []TSID) error {
var metricIDs uint64Sorter var metricIDs uint64Sorter
tsidsMap := make(map[uint64]*TSID)
prefetchedMetricIDs := s.prefetchedMetricIDs.Load().(*uint64set.Set) prefetchedMetricIDs := s.prefetchedMetricIDs.Load().(*uint64set.Set)
for i := range tsids { for i := range tsids {
metricID := tsids[i].MetricID metricID := tsids[i].MetricID
@ -723,6 +724,7 @@ func (s *Storage) prefetchMetricNames(tsids []TSID) error {
continue continue
} }
metricIDs = append(metricIDs, metricID) metricIDs = append(metricIDs, metricID)
tsidsMap[metricID] = &tsids[i]
} }
if len(metricIDs) < 500 { if len(metricIDs) < 500 {
// It is cheaper to skip pre-fetching and obtain metricNames inline. // It is cheaper to skip pre-fetching and obtain metricNames inline.
@ -734,7 +736,8 @@ func (s *Storage) prefetchMetricNames(tsids []TSID) error {
var metricName []byte var metricName []byte
var err error var err error
for _, metricID := range metricIDs { for _, metricID := range metricIDs {
metricName, err = s.searchMetricName(metricName[:0], metricID) tsid := tsidsMap[metricID]
metricName, err = s.searchMetricName(metricName[:0], metricID, tsid.AccountID, tsid.ProjectID)
if err != nil { if err != nil {
return fmt.Errorf("error in pre-fetching metricName for metricID=%d: %s", metricID, err) return fmt.Errorf("error in pre-fetching metricName for metricID=%d: %s", metricID, err)
} }