From a0e4e9afbfe47d7f3535b9293c3aaadef0322b70 Mon Sep 17 00:00:00 2001 From: pavel-usov <30620706+pavel-usov@users.noreply.github.com> Date: Mon, 17 Sep 2018 18:56:56 +0200 Subject: [PATCH 1/2] Update mysql.go Change in GET_LOCK call to make it MariaDB compatilble --- physical/mysql/mysql.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physical/mysql/mysql.go b/physical/mysql/mysql.go index 6500d2915375..4cb7466e6fac 100644 --- a/physical/mysql/mysql.go +++ b/physical/mysql/mysql.go @@ -620,7 +620,7 @@ 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) + rows, err := i.in.Query("SELECT GET_LOCK(?, 4294967295), IS_USED_LOCK(?)", i.key, i.key) if err != nil { return err } From cea148afd3d930ac73260968e459c02e6317fce8 Mon Sep 17 00:00:00 2001 From: pavel-usov <30620706+pavel-usov@users.noreply.github.com> Date: Wed, 19 Sep 2018 16:04:55 +0200 Subject: [PATCH 2/2] 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 4cb7466e6fac..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(?, 4294967295), 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 }