mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
clarify Head.appendableMinValidTime (#10303)
Signed-off-by: Dieter Plaetinck <dieter@grafana.com>
This commit is contained in:
parent
5a6e26556b
commit
aa8874bc56
|
@ -135,10 +135,18 @@ func (h *Head) appender() *headAppender {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// appendableMinValidTime returns the minimum valid timestamp for appends,
|
||||||
|
// such that samples stay ahead of prior blocks and the head compaction window.
|
||||||
func (h *Head) appendableMinValidTime() int64 {
|
func (h *Head) appendableMinValidTime() int64 {
|
||||||
// Setting the minimum valid time to whichever is greater, the head min valid time or the compaction window,
|
// This boundary ensures that no samples will be added to the compaction window.
|
||||||
// ensures that no samples will be added within the compaction window to avoid races.
|
// This allows race-free, concurrent appending and compaction.
|
||||||
return max(h.minValidTime.Load(), h.MaxTime()-h.chunkRange.Load()/2)
|
cwEnd := h.MaxTime() - h.chunkRange.Load()/2
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
minValid := h.minValidTime.Load()
|
||||||
|
|
||||||
|
return max(cwEnd, minValid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendableMinValidTime returns the minimum valid time for samples to be appended to the Head.
|
// AppendableMinValidTime returns the minimum valid time for samples to be appended to the Head.
|
||||||
|
|
Loading…
Reference in a new issue