Skip to content

Commit

Permalink
fix a data race
Browse files Browse the repository at this point in the history
Signed-off-by: lance6716 <lance6716@gmail.com>
  • Loading branch information
lance6716 committed Nov 4, 2022
1 parent fe27f1d commit 9155f42
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dm/config/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sort"
"strconv"
"strings"
"sync"
"time"

"github.com/coreos/go-semver/semver"
Expand Down Expand Up @@ -1008,11 +1009,16 @@ func AdjustDBTimeZone(config *DBConfig, timeZone string) {
config.Session["time_zone"] = timeZone
}

var defaultParser = parser.New()
var (
defaultParser = parser.New()
parserMu sync.Mutex
)

func checkValidExpr(expr string) error {
expr = "select " + expr
parserMu.Lock()
_, _, err := defaultParser.Parse(expr, "", "")
parserMu.Unlock()
return err
}

Expand Down

0 comments on commit 9155f42

Please sign in to comment.