From 5973fd406709fc2da5875ad2396e312cd060750a Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 10 Feb 2021 23:05:16 +0200 Subject: [PATCH] app/vmselect/promql: make a copy of EvalConfig when executing `q1` and `q2` in parallel for `q1 binary_op q2` This should prevent from data races if the underlying functions modify EvalConfig contents. --- app/vmselect/promql/eval.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/vmselect/promql/eval.go b/app/vmselect/promql/eval.go index 84bbd894e1..9768ddfae9 100644 --- a/app/vmselect/promql/eval.go +++ b/app/vmselect/promql/eval.go @@ -295,7 +295,8 @@ func evalExpr(ec *EvalConfig, e metricsql.Expr) ([]*timeseries, error) { wg.Add(1) go func() { defer wg.Done() - tss, err := evalExpr(ec, be.Left) + ecCopy := *ec + tss, err := evalExpr(&ecCopy, be.Left) mu.Lock() if err != nil { if errGlobal == nil { @@ -308,7 +309,8 @@ func evalExpr(ec *EvalConfig, e metricsql.Expr) ([]*timeseries, error) { wg.Add(1) go func() { defer wg.Done() - tss, err := evalExpr(ec, be.Right) + ecCopy := *ec + tss, err := evalExpr(&ecCopy, be.Right) mu.Lock() if err != nil { if errGlobal == nil {