mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08: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
|
// consistently, we explicitly remove the last value
|
||||||
// from the block interval here.
|
// from the block interval here.
|
||||||
head := NewRangeHead(db.head, mint, maxt-1)
|
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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -759,17 +759,20 @@ func (db *DB) Compact() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CompactHead compacts the given the RangeHead.
|
// 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()
|
db.cmtx.Lock()
|
||||||
defer db.cmtx.Unlock()
|
defer db.cmtx.Unlock()
|
||||||
|
|
||||||
return db.compactHead(head, mint, maxt)
|
return db.compactHead(head)
|
||||||
}
|
}
|
||||||
|
|
||||||
// compactHead compacts the given the RangeHead.
|
// compactHead compacts the given the RangeHead.
|
||||||
// The compaction mutex should be held before calling this method.
|
// The compaction mutex should be held before calling this method.
|
||||||
func (db *DB) compactHead(head *RangeHead, mint, maxt int64) (err error) {
|
func (db *DB) compactHead(head *RangeHead) (err error) {
|
||||||
uid, err := db.compactor.Write(db.dir, head, mint, maxt, nil)
|
// 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 {
|
if err != nil {
|
||||||
return errors.Wrap(err, "persist head block")
|
return errors.Wrap(err, "persist head block")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue