mirror of
https://github.com/prometheus/prometheus.git
synced 2026-02-03 20:39:32 -05:00
Merge 5a15925bc1 into 7769495a4a
This commit is contained in:
commit
87fffeb837
1 changed files with 8 additions and 1 deletions
|
|
@ -19,6 +19,7 @@ import (
|
|||
"fmt"
|
||||
"log/slog"
|
||||
"math"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/prometheus/model/exemplar"
|
||||
|
|
@ -120,12 +121,18 @@ func (h *Head) initTime(t int64) {
|
|||
if !h.minTime.CompareAndSwap(math.MaxInt64, t) {
|
||||
// Concurrent appends that are initializing.
|
||||
// Wait until h.maxTime is swapped to avoid minTime/maxTime races.
|
||||
antiDeadlockTimeout := time.After(500 * time.Millisecond)
|
||||
// This should complete in microseconds under normal operation.
|
||||
antiDeadlockTimeout := time.After(100 * time.Millisecond)
|
||||
for h.maxTime.Load() == math.MinInt64 {
|
||||
select {
|
||||
case <-antiDeadlockTimeout:
|
||||
// This should never happen in normal operation.
|
||||
// If it does, there may be a bug or the system is severely overloaded.
|
||||
h.logger.Warn("initTime timeout waiting for maxTime initialization")
|
||||
return
|
||||
default:
|
||||
// Yield to allow the initializing goroutine to complete.
|
||||
runtime.Gosched()
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue