Skip to content

Commit

Permalink
Merge pull request #10502 from hpbieker/hpb-no-series-rebuild-on-dele…
Browse files Browse the repository at this point in the history
…te-when-series-still-in-cache

No rebuild series index on delete when the series still exists in cache
  • Loading branch information
benbjohnson authored Feb 4, 2019
2 parents e9dee25 + 4083ae0 commit 5c2577d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ v1.8.0 [unreleased]

### Bugfixes

- [#10503](https://github.com/influxdata/influxdb/pull/10503): Delete rebuilds series index when series to be deleted are only found in cache.
- [#10504](https://github.com/influxdata/influxdb/issue/10504): Delete rebuilds series index when series to be deleted are outside timerange.

v1.7.0 [unreleased]
Expand Down
18 changes: 18 additions & 0 deletions tsdb/engine/tsm1/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,24 @@ func (e *Engine) deleteSeriesRange(seriesKeys [][]byte, min, max int64) error {
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
// the series from the index.
hasDeleted := false
Expand Down

0 comments on commit 5c2577d

Please sign in to comment.