From 3ac96c310bddd3973fdf000e6f76228e01556747 Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Fri, 25 Mar 2022 09:44:06 -0600 Subject: [PATCH] Address PR feedback --- expression/builtin_miscellaneous.go | 15 +++++++++++---- session/bootstrap.go | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/expression/builtin_miscellaneous.go b/expression/builtin_miscellaneous.go index 1f7351e5db941..59b385bd95533 100644 --- a/expression/builtin_miscellaneous.go +++ b/expression/builtin_miscellaneous.go @@ -204,10 +204,14 @@ func (b *builtinLockSig) evalInt(row chunk.Row) (int64, bool, error) { } // A timeout less than zero is expected to be treated as unlimited. // Because of our implementation being based on pessimistic locks, - // We set the timeout to the maximum value of innodb_lock_wait_timeout. - if timeout < 0 { - timeout = int64(variable.GetSysVar("innodb_lock_wait_timeout").MaxValue) - } + // We can't have a timeout greater than innodb_lock_wait_timeout. + maxTimeout := int64(variable.GetSysVar("innodb_lock_wait_timeout").MaxValue) + if timeout < 0 || timeout > maxTimeout { + timeout = maxTimeout + } + // Lock names are case insensitive. Because we can't rely on collations + // being enabled on the internal table, we have to lower it. + lockName = strings.ToLower(lockName) err = b.ctx.GetAdvisoryLock(lockName, timeout) if err != nil { switch err.(*terror.Error).Code() { @@ -259,6 +263,9 @@ func (b *builtinReleaseLockSig) evalInt(row chunk.Row) (int64, bool, error) { if err != nil { return 0, isNull, err } + // Lock names are case insensitive. Because we can't rely on collations + // being enabled on the internal table, we have to lower it. + lockName = strings.ToLower(lockName) released := int64(0) if b.ctx.ReleaseAdvisoryLock(lockName) { released = 1 diff --git a/session/bootstrap.go b/session/bootstrap.go index 13301b71029c0..d54837809c1c0 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -596,7 +596,7 @@ const ( // currentBootstrapVersion is defined as a variable, so we can modify its value for testing. // please make sure this is the largest version -var currentBootstrapVersion int64 = version86 +var currentBootstrapVersion int64 = version87 var ( bootstrapVersion = []func(Session, int64){