mirror of https://github.com/prometheus/prometheus
Fix regression in subsequent range op. compactions.
We have an anomaly whereby subsequent range operations fail to be compacted into one single range operation. This fixes such behavior.pull/84/head
parent
669abdfefe
commit
ceb6611957
|
@ -431,16 +431,12 @@ func optimizeForward(pending ops) (out ops) {
|
|||
continue
|
||||
case *getValuesAlongRangeOp:
|
||||
// Range queries should be concatenated if they overlap.
|
||||
pending = pending[1:len(pending)]
|
||||
|
||||
if next.GreedierThan(t) {
|
||||
t.through = next.through
|
||||
next.from = t.from
|
||||
|
||||
var (
|
||||
head = ops{t}
|
||||
)
|
||||
|
||||
pending = append(head, pending...)
|
||||
return optimizeForward(pending)
|
||||
} else {
|
||||
pending = pending[1:len(pending)]
|
||||
}
|
||||
case *getValuesAtIntervalOp:
|
||||
pending = pending[1:len(pending)]
|
||||
|
|
|
@ -321,6 +321,46 @@ func testOptimizeTimeGroups(t test.Tester) {
|
|||
},
|
||||
},
|
||||
},
|
||||
// Regression Validation 1: Multiple Overlapping Interval Requests
|
||||
// This one specific case expects no mutation.
|
||||
{
|
||||
in: ops{
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant,
|
||||
through: testInstant.Add(5 * time.Minute),
|
||||
},
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant.Add(15 * time.Second),
|
||||
through: testInstant.Add(15 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant.Add(30 * time.Second),
|
||||
through: testInstant.Add(30 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant.Add(45 * time.Second),
|
||||
through: testInstant.Add(45 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
},
|
||||
out: ops{
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant,
|
||||
through: testInstant.Add(5 * time.Minute),
|
||||
},
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant.Add(15 * time.Second),
|
||||
through: testInstant.Add(15 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant.Add(30 * time.Second),
|
||||
through: testInstant.Add(30 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant.Add(45 * time.Second),
|
||||
through: testInstant.Add(45 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -518,6 +558,34 @@ func testOptimizeForward(t test.Tester) {
|
|||
},
|
||||
},
|
||||
},
|
||||
// Regression Validation 1: Multiple Overlapping Interval Requests
|
||||
// We expect to find compaction.
|
||||
{
|
||||
in: ops{
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant,
|
||||
through: testInstant.Add(5 * time.Minute),
|
||||
},
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant.Add(15 * time.Second),
|
||||
through: testInstant.Add(15 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant.Add(30 * time.Second),
|
||||
through: testInstant.Add(30 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant.Add(45 * time.Second),
|
||||
through: testInstant.Add(45 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
},
|
||||
out: ops{
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant,
|
||||
through: testInstant.Add(45 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -1007,6 +1075,34 @@ func testOptimize(t test.Tester) {
|
|||
},
|
||||
},
|
||||
},
|
||||
// Regression Validation 1: Multiple Overlapping Interval Requests
|
||||
// We expect to find compaction.
|
||||
{
|
||||
in: ops{
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant,
|
||||
through: testInstant.Add(5 * time.Minute),
|
||||
},
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant.Add(15 * time.Second),
|
||||
through: testInstant.Add(15 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant.Add(30 * time.Second),
|
||||
through: testInstant.Add(30 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant.Add(45 * time.Second),
|
||||
through: testInstant.Add(45 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
},
|
||||
out: ops{
|
||||
&getValuesAlongRangeOp{
|
||||
from: testInstant,
|
||||
through: testInstant.Add(45 * time.Second).Add(5 * time.Minute),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue