Skip to content

Commit

Permalink
db: make sure blocks don't overlap
Browse files Browse the repository at this point in the history
Reduce `block.MaxTime` by 1 millisecond so that `blocks[1].MinTime ==
blocks[0].MaxTime + 1`.
  • Loading branch information
BenoitKnecht committed Jun 12, 2018
1 parent c848349 commit 23b26e7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ func (db *DB) compact() (changes bool, err error) {
break
}
mint, maxt := rangeForTimestamp(db.head.MinTime(), db.opts.BlockRanges[0])
maxt--

// Wrap head into a range that bounds all reads to it.
head := &rangeHead{
Expand Down Expand Up @@ -550,7 +551,7 @@ func (db *DB) reload(deleteable ...string) (err error) {
if len(blocks) == 0 {
return nil
}
maxt := blocks[len(blocks)-1].Meta().MaxTime
maxt := blocks[len(blocks)-1].Meta().MaxTime + 1

return errors.Wrap(db.head.Truncate(maxt), "head truncate failed")
}
Expand Down

0 comments on commit 23b26e7

Please sign in to comment.