mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Logging added for when compaction takes more than the block time range (#8151)
* Logging added for when compaction takes more than the block time range Signed-off-by: arthursens <arthursens2005@gmail.com> * Log only if no errors were already logged Signed-off-by: arthursens <arthursens2005@gmail.com> * Log duration as human readable string Signed-off-by: arthursens <arthursens2005@gmail.com> * Move logging from compactHead() to Compact() Signed-off-by: arthursens <arthursens2005@gmail.com> * Compute duration of all head compactions plus wal truncation Signed-off-by: arthursens <arthursens2005@gmail.com> * Remove named return added os first commits Signed-off-by: arthursens <arthursens2005@gmail.com> * Address nits Signed-off-by: arthursens <arthursens2005@gmail.com> * Change miliseconds to seconds to make fuzzit tests happy Signed-off-by: ArthurSens <arthursens2005@gmail.com>
This commit is contained in:
parent
f055690b34
commit
64a106c5dd
10
tsdb/db.go
10
tsdb/db.go
|
@ -805,6 +805,7 @@ func (db *DB) Compact() (returnErr error) {
|
||||||
).Err()
|
).Err()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
start := time.Now()
|
||||||
// Check whether we have pending head blocks that are ready to be persisted.
|
// Check whether we have pending head blocks that are ready to be persisted.
|
||||||
// They have the highest priority.
|
// They have the highest priority.
|
||||||
for {
|
for {
|
||||||
|
@ -839,6 +840,15 @@ func (db *DB) Compact() (returnErr error) {
|
||||||
return errors.Wrap(err, "WAL truncation in Compact")
|
return errors.Wrap(err, "WAL truncation in Compact")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compactionDuration := time.Since(start)
|
||||||
|
// TODO: change to milliseconds once fuzzit tests are removed
|
||||||
|
if int64(compactionDuration.Seconds())*1000 > db.head.chunkRange.Load() {
|
||||||
|
level.Warn(db.logger).Log(
|
||||||
|
"msg", "Head compaction took longer than the block time range, compactions are falling behind and won't be able to catch up",
|
||||||
|
"duration", compactionDuration.String(),
|
||||||
|
"block_range", db.head.chunkRange.Load(),
|
||||||
|
)
|
||||||
|
}
|
||||||
return db.compactBlocks()
|
return db.compactBlocks()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue