diff --git a/docs/victoriametrics/changelog/CHANGELOG.md b/docs/victoriametrics/changelog/CHANGELOG.md index 5c832ca90e..fcde8b43aa 100644 --- a/docs/victoriametrics/changelog/CHANGELOG.md +++ b/docs/victoriametrics/changelog/CHANGELOG.md @@ -42,6 +42,7 @@ See also [LTS releases](https://docs.victoriametrics.com/victoriametrics/lts-rel * BUGFIX: [vmsingle](https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/): properly execute graceful shutdown for vmsingle if `-maxIngestionRate` is configured. See [#10795](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/10795). * BUGFIX: [vmui](https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#vmui): fix time display on Alerting Rules page to use selected timezone. See [#10827](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/10827). * BUGFIX: [vmalert](https://docs.victoriametrics.com/victoriametrics/vmalert/): delete labels from rule results if they are specified with an empty string value in rule or group labels. See [#10766](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/10766). +* BUGFIX: [vmsingle](https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/) and `vmselect` in [VictoriaMetrics cluster](https://docs.victoriametrics.com/victoriametrics/cluster-victoriametrics/): fix incorrect evaluation of binary operations caused by an ordering bug (e.g. `10 - (3 + 3 + 4)` being evaluated as `10 - 3 + 3 + 4`). The issue was introduced in v1.140.0, v1.136.4, and v1.122.19. See [#10856](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/10856). ## [v1.140.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.140.0) diff --git a/go.mod b/go.mod index 6864b4b1ec..61c9272616 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/VictoriaMetrics/easyproto v1.2.0 github.com/VictoriaMetrics/fastcache v1.13.3 github.com/VictoriaMetrics/metrics v1.43.2 - github.com/VictoriaMetrics/metricsql v0.86.1 + github.com/VictoriaMetrics/metricsql v0.87.0 github.com/aws/aws-sdk-go-v2 v1.41.5 github.com/aws/aws-sdk-go-v2/config v1.32.14 github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.22.13 diff --git a/go.sum b/go.sum index 5d93bece2b..a07ef89eae 100644 --- a/go.sum +++ b/go.sum @@ -58,14 +58,10 @@ github.com/VictoriaMetrics/easyproto v1.2.0 h1:FJT9uNXA2isppFuJErbLqD306KoFlehl7 github.com/VictoriaMetrics/easyproto v1.2.0/go.mod h1:QlGlzaJnDfFd8Lk6Ci/fuLxfTo3/GThPs2KH23mv710= github.com/VictoriaMetrics/fastcache v1.13.3 h1:rBabE0iIxcqKEMCwUmwHZ9dgEqXerg8FRbRDUvC7OVc= github.com/VictoriaMetrics/fastcache v1.13.3/go.mod h1:hHXhl4DA2fTL2HTZDJFXWgW0LNjo6B+4aj2Wmng3TjU= -github.com/VictoriaMetrics/metrics v1.43.1 h1:j3Ba4l2K1q3pkvzPqt6aSiQ2DBlAEj3VPVeBtpR3t/Y= -github.com/VictoriaMetrics/metrics v1.43.1/go.mod h1:xDM82ULLYCYdFRgQ2JBxi8Uf1+8En1So9YUwlGTOqTc= github.com/VictoriaMetrics/metrics v1.43.2 h1:+8pIQEGwchKS5CYFyvv3LKvNXGi7baZ9hmIV4RHqibY= github.com/VictoriaMetrics/metrics v1.43.2/go.mod h1:xDM82ULLYCYdFRgQ2JBxi8Uf1+8En1So9YUwlGTOqTc= -github.com/VictoriaMetrics/metricsql v0.86.0 h1:IFD08amp+nkW6I+pB3+iyamewkIrbEojkQP4cmEbwkU= -github.com/VictoriaMetrics/metricsql v0.86.0/go.mod h1:d4EisFO6ONP/HIGDYTAtwrejJBBeKGQYiRl095bS4QQ= -github.com/VictoriaMetrics/metricsql v0.86.1 h1:GuNqbbIaWZ9eNa6dOCi6itG/fJ96TGOFV3KWLnAyC2o= -github.com/VictoriaMetrics/metricsql v0.86.1/go.mod h1:d4EisFO6ONP/HIGDYTAtwrejJBBeKGQYiRl095bS4QQ= +github.com/VictoriaMetrics/metricsql v0.87.0 h1:Koxh3GkB/Z0f3O0bEChVFxiE4YZoxYyn5TzmGJfSfaw= +github.com/VictoriaMetrics/metricsql v0.87.0/go.mod h1:d4EisFO6ONP/HIGDYTAtwrejJBBeKGQYiRl095bS4QQ= github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow= github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4= github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b h1:mimo19zliBX/vSQ6PWWSL9lK8qwHozUj03+zLoEB8O0= diff --git a/vendor/github.com/VictoriaMetrics/metricsql/parser.go b/vendor/github.com/VictoriaMetrics/metricsql/parser.go index 325f1fc13f..eb83a4d918 100644 --- a/vendor/github.com/VictoriaMetrics/metricsql/parser.go +++ b/vendor/github.com/VictoriaMetrics/metricsql/parser.go @@ -1933,11 +1933,11 @@ func (be *BinaryOpExpr) appendStringNoKeepMetricNames(dst []byte) []byte { } func (be *BinaryOpExpr) needLeftParens() bool { - return needBinaryOpArgParens(be.Left, be.Op, false) + return needBinaryOpArgParens(be.Left) } func (be *BinaryOpExpr) needRightParens() bool { - if needBinaryOpArgParens(be.Right, be.Op, true) { + if needBinaryOpArgParens(be.Right) { return true } switch t := be.Right.(type) { @@ -1974,26 +1974,10 @@ func (be *BinaryOpExpr) appendModifiers(dst []byte) []byte { return dst } -func needBinaryOpArgParens(arg Expr, parentOp string, isRight bool) bool { +func needBinaryOpArgParens(arg Expr) bool { switch t := arg.(type) { case *BinaryOpExpr: - // Parens are required when the child op priority not equal to parent o one. - // For example, a + b / c - d should be a + (b / c) - d. - if binaryOpPriority(t.Op) != binaryOpPriority(parentOp) { - return true - } - - // Same op: parens are only needed when the sub-expression is not a simple leaf chain. - if t.Op != parentOp { - if isRight && !isRightAssociativeBinaryOp(parentOp) { - return true - } - if !isRight && isRightAssociativeBinaryOp(parentOp) { - return true - } - } - - return !isBinaryOpLeafSimple(t) + return true case *RollupExpr: if be, ok := t.Expr.(*BinaryOpExpr); ok && be.KeepMetricNames { return true @@ -2004,26 +1988,6 @@ func needBinaryOpArgParens(arg Expr, parentOp string, isRight bool) bool { } } -func isBinaryOpLeafSimple(arg Expr) bool { - switch t := arg.(type) { - case *NumberExpr: - return true - case *MetricExpr: - metricName := t.getMetricName() - // Parens should be added if metric name equals to a reserved word, such as group_left - // For example, a + group_left should become a + (group_left). Otherwise, query won't be parsed. - return !isReservedBinaryOpIdent(metricName) - case *BinaryOpExpr: - if t.GroupModifier.Op != "" || t.KeepMetricNames || t.JoinModifier.Op != "" { - return false - } - - return isBinaryOpLeafSimple(t.Left) && isBinaryOpLeafSimple(t.Right) - default: - return false - } -} - func isReservedBinaryOpIdent(s string) bool { return isBinaryOpGroupModifier(s) || isBinaryOpJoinModifier(s) || isBinaryOpBoolModifier(s) || isPrefixModifier(s) } diff --git a/vendor/modules.txt b/vendor/modules.txt index 9c9cbfba15..037fda8da5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -145,7 +145,7 @@ github.com/VictoriaMetrics/fastcache # github.com/VictoriaMetrics/metrics v1.43.2 ## explicit; go 1.24.0 github.com/VictoriaMetrics/metrics -# github.com/VictoriaMetrics/metricsql v0.86.1 +# github.com/VictoriaMetrics/metricsql v0.87.0 ## explicit; go 1.24.2 github.com/VictoriaMetrics/metricsql github.com/VictoriaMetrics/metricsql/binaryop