Do not rebuild series index on delete when the series still exists in the cache.

pull/10502/head
Hans Petter Bieker 2018-11-20 09:46:31 +01:00
parent f2cf118473
commit 926f78d832
1 changed files with 18 additions and 0 deletions

View File

@ -1614,6 +1614,24 @@ func (e *Engine) deleteSeriesRange(seriesKeys [][]byte, min, max int64) error {
return err return err
} }
// The seriesKeys slice is mutated if they are still found in the cache.
cacheKeys := e.Cache.Keys()
for i := 0; i < len(seriesKeys); i++ {
seriesKey := seriesKeys[i]
// Already crossed out
if len(seriesKey) == 0 {
continue
}
j := bytesutil.SearchBytes(cacheKeys, seriesKey)
if j < len(cacheKeys) {
cacheSeriesKey, _ := SeriesAndFieldFromCompositeKey(cacheKeys[j])
if bytes.Equal(seriesKey, cacheSeriesKey) {
seriesKeys[i] = emptyBytes
}
}
}
// Have we deleted all values for the series? If so, we need to remove // Have we deleted all values for the series? If so, we need to remove
// the series from the index. // the series from the index.
hasDeleted := false hasDeleted := false