vmselect: fix vmrangeBucketsToLE func may panic when ts value equal zero (#2902)

Co-authored-by: alanwzliang <alanwzliang@tencent.com>
This commit is contained in:
Alan Liang 2022-07-25 15:49:48 +08:00 committed by Aliaksandr Valialkin
parent f148cffc8a
commit c826f06366
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -572,19 +572,21 @@ func vmrangeBucketsToLE(tss []*timeseries) []*timeseries {
}) })
} }
xss = xssNew xss = xssNew
for i := range xss[0].ts.Values { if len(xss) > 0 {
count := float64(0) for i := range xss[0].ts.Values {
for _, xs := range xss { count := float64(0)
ts := xs.ts for _, xs := range xss {
v := ts.Values[i] ts := xs.ts
if !math.IsNaN(v) && v > 0 { v := ts.Values[i]
count += v if !math.IsNaN(v) && v > 0 {
count += v
}
ts.Values[i] = count
} }
ts.Values[i] = count
} }
} for _, xs := range xss {
for _, xs := range xss { rvs = append(rvs, xs.ts)
rvs = append(rvs, xs.ts) }
} }
} }
return rvs return rvs