diff --git a/app/vmselect/promql/binary_op.go b/app/vmselect/promql/binary_op.go index 7d827607a1..d258d63301 100644 --- a/app/vmselect/promql/binary_op.go +++ b/app/vmselect/promql/binary_op.go @@ -252,16 +252,21 @@ func mergeNonOverlappingTimeseries(dst, src *timeseries) bool { // Verify whether the time series can be merged. srcValues := src.Values dstValues := dst.Values + overlaps := 0 _ = dstValues[len(srcValues)-1] for i, v := range srcValues { if math.IsNaN(v) { continue } if !math.IsNaN(dstValues[i]) { - return false + overlaps++ } } - + // Allow up to two overlapping datapoints, which can appear due to staleness algorithm, + // which can add a few datapoints in the end of time series. + if overlaps > 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 361d7d61fc..4780edae11 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,8 @@ # tip +* BUGFIX: reduce the probability of `duplicate time series` errors when querying Kubernetes metrics. + # [v1.54.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.54.1)