From e020e7eea6aaeccac2ac1e757e73cfe8e32ccf90 Mon Sep 17 00:00:00 2001 From: pavel-usov <30620706+pavel-usov@users.noreply.github.com> Date: Wed, 19 Sep 2018 21:05:05 +0200 Subject: [PATCH] Change in GET_LOCK call to make it MariaDB compatilble (#5343) * Update mysql.go Change in GET_LOCK call to make it MariaDB compatilble * Use math.MaxUint32 for lock timeout, add comments --- physical/mysql/mysql.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/physical/mysql/mysql.go b/physical/mysql/mysql.go index 6500d2915375..af666b5d6cc5 100644 --- a/physical/mysql/mysql.go +++ b/physical/mysql/mysql.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "io/ioutil" + "math" "net/url" "sort" "strconv" @@ -620,7 +621,9 @@ func (i *MySQLLock) becomeLeader() error { func (i *MySQLLock) Lock() error { defer metrics.MeasureSince([]string{"mysql", "get_lock"}, time.Now()) - rows, err := i.in.Query("SELECT GET_LOCK(?, -1), IS_USED_LOCK(?)", i.key, i.key) + // Lock timeout math.MaxUint32 instead of -1 solves compatibility issues with + // different MySQL flavours i.e. MariaDB + rows, err := i.in.Query("SELECT GET_LOCK(?, ?), IS_USED_LOCK(?)", i.key, math.MaxUint32, i.key) if err != nil { return err }