Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL: GET_LOCK limits and issues

Tags:

mysql

locking

I a need a database level synchronization. For this I'm using GET_LOCK('prefix.some_id', 0). At some moment GET_LOCK returns 1 for same key in different scripts on different hosts. What could be the problem? I need lots of those locks, 5-7k approximately.

Any ideas?

like image 348
Daniel Avatar asked Dec 13 '22 09:12

Daniel


2 Answers

MySQL 5.7.5 and MariaDB 10.0.2 both support your use case now.

For MySQL see: https://dev.mysql.com/doc/refman/5.7/en/locking-functions.html

For MariaDB see: https://mariadb.com/kb/en/mariadb/documentation/functions-and-operators/miscellaneous-functions/get_lock/

like image 155
Ethan Avatar answered Jan 06 '23 16:01

Ethan


Bug #1118 Allow multiple concurrent locks with GET_LOCK()

like image 23
Daniel Avatar answered Jan 06 '23 16:01

Daniel