MySQL Plugin Services •The locking interface treats namespace and lock names as binary strings, so comparisons are case- sensitive. •The locking interface provides functions to acquire locks and release locks. No special privilege is required to call these functions. Privilege checking is the responsibility of the calling application. •Locks can be waited for if not immediately available. Lock acquisition calls take an integer timeout value that indicates how many seconds to wait to acquire locks before giving up. If the timeout is reached without successful lock acquisition, an  ER_LOCKING_SERVICE_TIMEOUT  error occurs. If the timeout is 0, there is no waiting and the call produces an error if locks cannot be acquired immediately. •The locking interface detects deadlock between lock-acquisition calls in different sessions. In this case, the locking service chooses a caller and terminates its lock-acquisition request with an ER_LOCKING_SERVICE_DEADLOCK  error. This error does not cause transactions to roll back. To choose a session in case of deadlock, the locking service prefers sessions that hold read locks over sessions that hold write locks. •A session can acquire multiple locks with a single lock-acquisition call. For a given call, lock acquisition is atomic: The call succeeeds if all locks are acquired. If acquisition of any lock fails, the call acquires no locks and fails, typically with an  ER_LOCKING_SERVICE_TIMEOUT  or ER_LOCKING_SERVICE_DEADLOCK  error. •A session can acquire multiple locks for the same lock identifier (namespace and lock name combination). These lock instances can be read locks, write locks, or a mix of both. •Locks acquired within a session are released explicitly by calling a release-locks function, or implicitly when the session terminates (either normally or abnormally). Locks are not released when transactions commit or roll back. •Within a session, all locks for a given namespace when released are released together. • opaque_thd : A thread handle. If specified as  NULL , the handle for the current thread is used. 1136 The arguments have these meanings: The interface provided by the locking service is distinct from that provided by  GET_LOCK()  and related SQL functions (see Section 12.15, “Locking Functions” ). For example,  GET_LOCK()  does not implement namespaces and provides only exclusive locks, not distinct read and write locks. This section describes how to use the locking service C language interface. To use the function interface instead, see The Locking Service Function Interface For general characteristics of the locking service interface, see Section 5.6.9.1, “The Locking Service” . For general information about plugin services, see Section 5.6.9, “MySQL Plugin Services” . Source files that use the locking service should include this header file: #include <mysql/service_locking.h> To acquire one or more locks, call this function: The Locking Service C Interface int mysql_acquire_locking_service_locks(MYSQL_THD opaque_thd, const char* lock_namespace, const char**lock_names, size_t lock_num, enum enum_locking_service_lock_type lock_type, unsigned long lock_timeout);