mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-10 15:14:09 +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 {
|
||||
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 {
|
||||
timestamps[j] += queryOffset
|
||||
}
|
||||
r.Timestamps = timestamps
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1011,7 +1015,9 @@ func removeEmptyValuesAndTimeseries(tss []netstorage.Result) []netstorage.Result
|
|||
// Slow path: remove NaNs.
|
||||
srcTimestamps := ts.Timestamps
|
||||
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 {
|
||||
if math.IsNaN(v) {
|
||||
continue
|
||||
|
|
|
@ -16,6 +16,9 @@ The following tip changes can be tested by building VictoriaMetrics components f
|
|||
## 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)
|
||||
|
||||
Released at 2023-01-10
|
||||
|
|
Loading…
Reference in a new issue