From c16e17dedeaf66b03685aea23c4fd83f8fe9d0c2 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 9 Nov 2019 18:48:58 +0200 Subject: [PATCH] lib/storage: properly set time range when deleting time series --- lib/storage/index_db.go | 6 +++++- lib/storage/storage_test.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go index 4dc275a0e..f36f5eb7c 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -903,8 +903,12 @@ func (db *indexDB) DeleteTSIDs(tfss []*TagFilters) (int, error) { } // Obtain metricIDs to delete. + tr := TimeRange{ + MinTimestamp: 0, + MaxTimestamp: (1<<63)-1, + } is := db.getIndexSearch() - metricIDs, err := is.searchMetricIDs(tfss, TimeRange{}, 1e9) + metricIDs, err := is.searchMetricIDs(tfss, tr, 1e12) db.putIndexSearch(is) if err != nil { return 0, err diff --git a/lib/storage/storage_test.go b/lib/storage/storage_test.go index 82b956c9f..27814cf56 100644 --- a/lib/storage/storage_test.go +++ b/lib/storage/storage_test.go @@ -581,7 +581,7 @@ func testStorageDeleteMetrics(s *Storage, workerNum int) error { return fmt.Errorf("cannot delete metrics: %s", err) } if deletedCount == 0 { - return fmt.Errorf("expecting non-zero number of deleted metrics") + return fmt.Errorf("expecting non-zero number of deleted metrics on iteration %d", i) } if n := metricBlocksCount(tfs); n != 0 { return fmt.Errorf("expecting zero metric blocks after DeleteMetrics call for tfs=%s; got %d blocks", tfs, n)