MySQL Plugin Services SONAME ’locking_service.so’; CREATE FUNCTION service_release_locks RETURNS INT SONAME ’locking_service.so’; DROP FUNCTION service_get_read_locks; DROP FUNCTION service_get_write_locks; DROP FUNCTION service_release_locks; mysql>  SELECT service_get_read_locks(’mynamespace’, ’rlock1’, ’rlock2’, 10); +---------------------------------------------------------------+ | service_get_read_locks(’mynamespace’, ’rlock1’, ’rlock2’, 10) | +---------------------------------------------------------------+ | 1 | +---------------------------------------------------------------+ mysql>  SELECT service_get_write_locks(’mynamespace’, ’wlock1’, ’wlock2’, 10); +----------------------------------------------------------------+ | service_get_write_locks(’mynamespace’, ’wlock1’, ’wlock2’, 10) | +----------------------------------------------------------------+ | 1 | +----------------------------------------------------------------+ mysql>  SELECT service_release_locks(’mynamespace’); +--------------------------------------+ | service_release_locks(’mynamespace’) | +--------------------------------------+ | 1 | +--------------------------------------+ mysql>  SELECT service_get_read_locks(’mynamespace’, ’’, 10); ERROR 3131 (42000): Incorrect locking service lock name ’’. 1138 A session can acquire multiple locks for the same lock identifier. As long as a different session does not have a write lock for an identifier, the session can acquire any number of read or write locks. Each lock Each locking function returns nonzero for success. If the function fails, an error occurs. For example, the following error occurs because lock names cannot be empty: To release all locks for a namespace, use this function: In this case, the lock identifiers are  (mynamespace, wlock1)  and  (mynamespace, wlock2) . To acquire write locks rather than read locks, call this function: For the example just shown, the function acquires locks with lock identifiers  (mynamespace, rlock1) and  (mynamespace, rlock2) . The first argument is the lock namespace. The final argument is an integer timeout indicating how many seconds to wait to acquire the locks before giving up. The arguments in between are the lock names. Before using the locking service functions, install them according to the instructions provided at Installing or Uninstalling the Locking Service Function Interface. To acquire one or more read locks, call this function: Once installed, the functions remain installed until uninstalled. To remove them, use the  DROP FUNCTION statement: If the functions are used on a replication source server, install them on all replica servers as well to avoid replication problems. Using the Locking Service Function Interface