Skip to content

Commit 54957d4

Browse files
authored
mysql 5.7 onwards has a 64 character limit
for the lockstring, so use a hash for the key
1 parent 1acab41 commit 54957d4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sqlock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ children=( "$!" $(jobs -rp) )
9595
disown
9696

9797
# Now try and get the lock
98-
echo "SELECT IF(GET_LOCK('$lockstring',$LOCKTIMEOUT_SECONDS)=1,'Got lock', concat('Already locked by connection: ', IS_USED_LOCK('$lockstring')));" >$fifo
98+
echo "SELECT IF(GET_LOCK(sha1('$lockstring'),$LOCKTIMEOUT_SECONDS)=1,'Got lock', concat('Already locked by connection: ', IS_USED_LOCK('$lockstring')));" >$fifo
9999

100100
# Sleep for long enough to see whether we got the lock - we add 1 second
101101
# to the timeout, because the fifo output can still suffer from a slight delay
@@ -107,6 +107,6 @@ grep -q "Got lock" "$tmpdir"/sql.log || (grep "Already locked" "$tmpdir"/sql.log
107107
"$@"
108108

109109
# release the lock
110-
echo "SELECT RELEASE_LOCK('$lockstring');" >$fifo
110+
echo "SELECT RELEASE_LOCK(sha1('$lockstring'));" >$fifo
111111

112112
tidyup

0 commit comments

Comments
 (0)