mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 21:54:10 -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()
|
||||
}()
|
||||
|
||||
start := time.Now()
|
||||
// Check whether we have pending head blocks that are ready to be persisted.
|
||||
// They have the highest priority.
|
||||
for {
|
||||
|
@ -839,6 +840,15 @@ func (db *DB) Compact() (returnErr error) {
|
|||
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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue