mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/promql: fix panic on a single zero vmrange bucket in prometheus_buckets() function
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/296
This commit is contained in:
parent
81ba371eaf
commit
3e304890a6
2 changed files with 18 additions and 0 deletions
|
@ -2964,6 +2964,23 @@ func TestExecSuccess(t *testing.T) {
|
||||||
resultExpected := []netstorage.Result{r1, r2, r3, r4, r5, r6}
|
resultExpected := []netstorage.Result{r1, r2, r3, r4, r5, r6}
|
||||||
f(q, resultExpected)
|
f(q, resultExpected)
|
||||||
})
|
})
|
||||||
|
t.Run(`prometheus_buckets(zero-vmrange-value)`, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
q := `sort(prometheus_buckets(label_set(0, "vmrange", "0...0")))`
|
||||||
|
r1 := netstorage.Result{
|
||||||
|
MetricName: metricNameExpected,
|
||||||
|
Values: []float64{0, 0, 0, 0, 0, 0},
|
||||||
|
Timestamps: timestampsExpected,
|
||||||
|
}
|
||||||
|
r1.MetricName.Tags = []storage.Tag{
|
||||||
|
{
|
||||||
|
Key: []byte("le"),
|
||||||
|
Value: []byte("+Inf"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
resultsExpected := []netstorage.Result{r1}
|
||||||
|
f(q, resultsExpected)
|
||||||
|
})
|
||||||
t.Run(`prometheus_buckets(valid)`, func(t *testing.T) {
|
t.Run(`prometheus_buckets(valid)`, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
q := `sort(prometheus_buckets((
|
q := `sort(prometheus_buckets((
|
||||||
|
|
|
@ -363,6 +363,7 @@ func vmrangeBucketsToLE(tss []*timeseries) []*timeseries {
|
||||||
ts := xs.ts
|
ts := xs.ts
|
||||||
if isZeroTS(ts) {
|
if isZeroTS(ts) {
|
||||||
// Skip time series with zeros. They are substituted by xssNew below.
|
// Skip time series with zeros. They are substituted by xssNew below.
|
||||||
|
xsPrev = xs
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if xs.start != xsPrev.end {
|
if xs.start != xsPrev.end {
|
||||||
|
|
Loading…
Reference in a new issue