mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Debug corner-case seeking anomaly.
This commit is contained in:
parent
be9b7942c1
commit
ac438e51f6
|
@ -366,12 +366,36 @@ func (l *LevelDBMetricPersistence) GetValueAtTime(m *model.Metric, t *time.Time,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peekAhead := false
|
||||||
|
|
||||||
if !fingerprintsEqual(firstKey.Fingerprint, k.Fingerprint) {
|
if !fingerprintsEqual(firstKey.Fingerprint, k.Fingerprint) {
|
||||||
return
|
/*
|
||||||
|
* This allows us to grab values for metrics if our request time is after
|
||||||
|
* the last recorded time subject to the staleness policy due to the nuances
|
||||||
|
* of LevelDB storage:
|
||||||
|
*
|
||||||
|
* # Assumptions:
|
||||||
|
* - K0 < K1 in terms of sorting.
|
||||||
|
* - T0 < T1 in terms of sorting.
|
||||||
|
*
|
||||||
|
* # Data
|
||||||
|
*
|
||||||
|
* K0-T0
|
||||||
|
* K0-T1
|
||||||
|
* K0-T2
|
||||||
|
* K1-T0
|
||||||
|
* K1-T1
|
||||||
|
*
|
||||||
|
* # Scenario
|
||||||
|
* K0-T3, which does not exist, is requested. LevelDB will thusly seek to
|
||||||
|
* K1-T1, when K0-T2 exists as a perfectly good candidate to check subject
|
||||||
|
* to the provided staleness policy and such.
|
||||||
|
*/
|
||||||
|
peekAhead = true
|
||||||
}
|
}
|
||||||
|
|
||||||
firstTime := indexable.DecodeTime(firstKey.Timestamp)
|
firstTime := indexable.DecodeTime(firstKey.Timestamp)
|
||||||
if t.Before(firstTime) {
|
if t.Before(firstTime) || peekAhead {
|
||||||
iterator.Prev()
|
iterator.Prev()
|
||||||
if !iterator.Valid() {
|
if !iterator.Valid() {
|
||||||
/*
|
/*
|
||||||
|
@ -395,7 +419,10 @@ func (l *LevelDBMetricPersistence) GetValueAtTime(m *model.Metric, t *time.Time,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if fingerprintsEqual(alternativeKey.Fingerprint, k.Fingerprint) {
|
if !fingerprintsEqual(alternativeKey.Fingerprint, k.Fingerprint) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At this point, we found a previous value in the same series in the
|
* At this point, we found a previous value in the same series in the
|
||||||
* database. LevelDB originally seeked to the subsequent element given
|
* database. LevelDB originally seeked to the subsequent element given
|
||||||
|
@ -407,7 +434,6 @@ func (l *LevelDBMetricPersistence) GetValueAtTime(m *model.Metric, t *time.Time,
|
||||||
firstValue = alternativeValue
|
firstValue = alternativeValue
|
||||||
firstTime = alternativeTime
|
firstTime = alternativeTime
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
firstDelta := firstTime.Sub(*t)
|
firstDelta := firstTime.Sub(*t)
|
||||||
if firstDelta < 0 {
|
if firstDelta < 0 {
|
||||||
|
|
Loading…
Reference in a new issue