BigHelmet
BigHelmet

Reputation: 1

Set infinite timeout GET_LOCK() in MariaDB

GET_LOCK() in MySQL, accepts a negative value for timeout and is interpret as infinite timeout.

MySQL Documentation: GET_LOCK()

Tries to obtain a lock with a name given by the string str, using a timeout of timeout seconds. A negative timeout value means infinite timeout. The lock is exclusive. While held by one session, other sessions cannot obtain a lock of the same name.

But in MariaDB I can't find the way to replicate that infinite timeout, because there's nothing specified in the documentation.

MariaDB Documentation: GET_LOCK()

GET_LOCK(str,timeout) [...] str is case insensitive for GET_LOCK() and related functions. If str is an empty string or NULL, GET_LOCK() returns NULL and does nothing. timeout is rounded to the closest integer.

I could replicate GET_LOCK() with infinite timeout of MySQL in MariaDB?

Upvotes: 0

Views: 962

Answers (1)

markusjm
markusjm

Reputation: 2562

MariaDB does not accept negative values for GET_LOCK:

MariaDB [test]> do get_lock('test', -1);
Query OK, 0 rows affected, 1 warning (0.00 sec)

MariaDB [test]> show warnings;
+---------+------+-----------------------------------------------------+
| Level   | Code | Message                                             |
+---------+------+-----------------------------------------------------+
| Warning | 1411 | Incorrect timeout value: '-1' for function get_lock |
+---------+------+-----------------------------------------------------+
1 row in set (0.00 sec)

What you can do is use 0xffffffff to emulate the same behavior in MariaDB:

MariaDB [test]> do get_lock('test', 0xffffff);
Query OK, 0 rows affected (1.85 sec)

Upvotes: 3

Related Questions