Skip to content

Commit

Permalink
Change in GET_LOCK call to make it MariaDB compatilble (#5343)
Browse files Browse the repository at this point in the history
* Update mysql.go

Change in GET_LOCK call to make it MariaDB compatilble

* Use math.MaxUint32 for lock timeout, add comments
  • Loading branch information
pavel-usov authored and briankassouf committed Sep 19, 2018
1 parent 6e8d91a commit e020e7e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion physical/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"math"
"net/url"
"sort"
"strconv"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit e020e7e

Please sign in to comment.