diff --git a/tsdb/db.go b/tsdb/db.go index f63437fc6..dc94806df 100644 --- a/tsdb/db.go +++ b/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() }