mirror of
https://github.com/prometheus/prometheus
synced 2024-12-25 16:02:28 +00:00
Use min and maxt of the range head when creating a block (#7282)
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
This commit is contained in:
parent
09df8d94e0
commit
f4dd45609a
13
tsdb/db.go
13
tsdb/db.go
@ -750,7 +750,7 @@ func (db *DB) Compact() (err error) {
|
||||
// consistently, we explicitly remove the last value
|
||||
// from the block interval here.
|
||||
head := NewRangeHead(db.head, mint, maxt-1)
|
||||
if err := db.compactHead(head, mint, maxt); err != nil {
|
||||
if err := db.compactHead(head); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -759,17 +759,20 @@ func (db *DB) Compact() (err error) {
|
||||
}
|
||||
|
||||
// CompactHead compacts the given the RangeHead.
|
||||
func (db *DB) CompactHead(head *RangeHead, mint, maxt int64) (err error) {
|
||||
func (db *DB) CompactHead(head *RangeHead) (err error) {
|
||||
db.cmtx.Lock()
|
||||
defer db.cmtx.Unlock()
|
||||
|
||||
return db.compactHead(head, mint, maxt)
|
||||
return db.compactHead(head)
|
||||
}
|
||||
|
||||
// compactHead compacts the given the RangeHead.
|
||||
// The compaction mutex should be held before calling this method.
|
||||
func (db *DB) compactHead(head *RangeHead, mint, maxt int64) (err error) {
|
||||
uid, err := db.compactor.Write(db.dir, head, mint, maxt, nil)
|
||||
func (db *DB) compactHead(head *RangeHead) (err error) {
|
||||
// Add +1 millisecond to block maxt because block intervals are half-open: [b.MinTime, b.MaxTime).
|
||||
// Because of this block intervals are always +1 than the total samples it includes.
|
||||
maxt := head.MaxTime() + 1
|
||||
uid, err := db.compactor.Write(db.dir, head, head.MinTime(), maxt, nil)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "persist head block")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user