From 2ab4cea5e508f50b1559872b21d06c7c21552481 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin <valyala@gmail.com> Date: Sat, 16 Nov 2019 12:11:22 +0200 Subject: [PATCH] lib/storage: always start using per-day inverted index on the next day after its creation The current day could miss entries for already stopped time series before enabling per-day index. This fixes the issue when queries return empty results during the first hour after upgrading to v1.29.* --- lib/storage/index_db.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go index 8192dfef6f..5f54442bcf 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -1001,8 +1001,9 @@ func (is *indexSearch) getStartDateForPerDayInvertedIndex() (uint64, error) { if err := ts.Error(); err != nil { return 0, err } - // The database is empty. Return the current date. - return minDate, nil + // There are no (date,tag)->metricIDs entries in the database yet. + // Return the next date, since the current date may contain unindexed data. + return minDate + 1, nil } func (is *indexSearch) loadDeletedMetricIDs() (*uint64set.Set, error) {