diff --git a/app/vmselect/promql/binary_op.go b/app/vmselect/promql/binary_op.go index d258d6330..b103b2075 100644 --- a/app/vmselect/promql/binary_op.go +++ b/app/vmselect/promql/binary_op.go @@ -267,6 +267,12 @@ func mergeNonOverlappingTimeseries(dst, src *timeseries) bool { if overlaps > 2 { return false } + // Do not merge time series with too small number of datapoints. + // This can be the case during evaluation of instant queries (alerting or recording rules). + // See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1141 + if len(srcValues) <= 2 && len(dstValues) <= 2 { + return false + } // Time series can be merged. Merge them. for i, v := range srcValues { if math.IsNaN(v) { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ace1d4f6a..22727f9d2 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -14,6 +14,7 @@ * BUGFIX: prevent from infinite loop on `{__graphite__="..."}` filters when a metric name contains `*`, `{` or `[` chars. * BUGFIX: prevent from infinite loop in `/metrics/find` and `/metrics/expand` [Graphite Metrics API handlers](https://victoriametrics.github.io/#graphite-metrics-api-usage) when they match metric names or labels with `*`, `{` or `[` chars. +* BUGFIX: do not merge duplicate time series during requests to `/api/v1/query`. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1141 # [v1.56.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.56.0)