From a45f25699cfc2fd5b05c23104fecc7a7131a3e97 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Fri, 31 Jan 2020 00:54:28 +0200 Subject: [PATCH] lib/storage: re-use indexSearch inside Storage.prefetchMetricNames --- lib/storage/storage.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/storage/storage.go b/lib/storage/storage.go index c605c5a30f..13e89a106b 100644 --- a/lib/storage/storage.go +++ b/lib/storage/storage.go @@ -2,6 +2,7 @@ package storage import ( "fmt" + "io" "io/ioutil" "math" "os" @@ -735,10 +736,13 @@ func (s *Storage) prefetchMetricNames(tsids []TSID) error { sort.Sort(metricIDs) var metricName []byte var err error + idb := s.idb() + is := idb.getIndexSearch() + defer idb.putIndexSearch(is) for _, metricID := range metricIDs { tsid := tsidsMap[metricID] - metricName, err = s.searchMetricName(metricName[:0], metricID, tsid.AccountID, tsid.ProjectID) - if err != nil { + metricName, err = is.searchMetricName(metricName[:0], metricID, tsid.AccountID, tsid.ProjectID) + if err != nil && err != io.EOF { return fmt.Errorf("error in pre-fetching metricName for metricID=%d: %s", metricID, err) } }