mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
app/vmselect/promql: make a copy of per-series timestamps before their modification
The per-series timestamps are usually shared among series, so it is unsafe modifying them.
The issue has been appeared after the optimization at 2f3ddd4884
This commit is contained in:
parent
8a35377cf3
commit
3d22532bb8
2 changed files with 11 additions and 2 deletions
|
@ -864,10 +864,14 @@ func QueryHandler(qt *querytracer.Tracer, startTime time.Time, at *auth.Token, w
|
||||||
}
|
}
|
||||||
if queryOffset > 0 {
|
if queryOffset > 0 {
|
||||||
for i := range result {
|
for i := range result {
|
||||||
timestamps := result[i].Timestamps
|
r := &result[i]
|
||||||
|
// Do not modify r.Timestamps, since they may be shared among multiple series.
|
||||||
|
// Make a copy instead.
|
||||||
|
timestamps := append([]int64{}, r.Timestamps...)
|
||||||
for j := range timestamps {
|
for j := range timestamps {
|
||||||
timestamps[j] += queryOffset
|
timestamps[j] += queryOffset
|
||||||
}
|
}
|
||||||
|
r.Timestamps = timestamps
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1011,7 +1015,9 @@ func removeEmptyValuesAndTimeseries(tss []netstorage.Result) []netstorage.Result
|
||||||
// Slow path: remove NaNs.
|
// Slow path: remove NaNs.
|
||||||
srcTimestamps := ts.Timestamps
|
srcTimestamps := ts.Timestamps
|
||||||
dstValues := ts.Values[:0]
|
dstValues := ts.Values[:0]
|
||||||
dstTimestamps := ts.Timestamps[:0]
|
// Do not re-use ts.Timestamps for dstTimestamps, since ts.Timestamps
|
||||||
|
// may be shared among multiple time series.
|
||||||
|
dstTimestamps := make([]int64{}, 0, len(ts.Timestamps))
|
||||||
for j, v := range ts.Values {
|
for j, v := range ts.Values {
|
||||||
if math.IsNaN(v) {
|
if math.IsNaN(v) {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -16,6 +16,9 @@ The following tip changes can be tested by building VictoriaMetrics components f
|
||||||
## tip
|
## tip
|
||||||
|
|
||||||
|
|
||||||
|
* BUGFIX: return correct query results over time series with gaps. The issue has been introduced in [v1.86.0](https://docs.victoriametrics.com/CHANGELOG.html#v1860).
|
||||||
|
|
||||||
|
|
||||||
## [v1.86.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.86.0)
|
## [v1.86.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.86.0)
|
||||||
|
|
||||||
Released at 2023-01-10
|
Released at 2023-01-10
|
||||||
|
|
Loading…
Reference in a new issue