我需要数据库级同步。为此,我正在使用GET_LOCK('prefix.some_id',0)。有时,GET_LOCK对于不同主机上不同脚本中的相同密钥返回1。可能是什么问题呢?我需要很多这些锁,大约5-7k。
有任何想法吗?
MySQL 5.7.5和MariaDB 10.0.2现在都支持您的用例。
对于MySQL,请参见:http : //dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_get-lock
对于MariaDB,请参见:https : //mariadb.com/kb/zh-CN/mariadb/documentation/functions-and-operators/miscellaneous-functions/get_lock/