diff --git a/tsdb/head.go b/tsdb/head.go index 7763d272b7..c2a1dc0c0e 100644 --- a/tsdb/head.go +++ b/tsdb/head.go @@ -62,6 +62,8 @@ var ( defaultIsolationDisabled = false defaultWALReplayConcurrency = runtime.GOMAXPROCS(0) + + compactibleRatio = 1.1 ) // Head handles reads and writes of time series data within a time window. @@ -1700,7 +1702,7 @@ func (h *Head) compactable() bool { return false } - return h.MaxTime()-h.MinTime() > h.chunkRange.Load()/2*3 + return h.MaxTime()-h.MinTime() > int64(float64(h.chunkRange.Load())*compactibleRatio) } // Close flushes the WAL and closes the head. diff --git a/tsdb/head_append.go b/tsdb/head_append.go index 03800b2455..4a680f4d03 100644 --- a/tsdb/head_append.go +++ b/tsdb/head_append.go @@ -194,7 +194,7 @@ func (h *Head) appender() *headAppender { func (h *Head) appendableMinValidTime() int64 { // This boundary ensures that no samples will be added to the compaction window. // This allows race-free, concurrent appending and compaction. - cwEnd := h.MaxTime() - h.chunkRange.Load()/2 + cwEnd := h.MaxTime() - int64(float64(h.chunkRange.Load())*(compactibleRatio-1)) // This boundary ensures that we avoid overlapping timeframes from one block to the next. // While not necessary for correctness, it means we're not required to use vertical compaction.