Documentation Home
MySQL NDB Cluster API Developer Guide
Download this Manual NdbOperation::getLockHandle

Description.  Returns a pointer to the current operation's lock handle. When used with NdbRecord, the lock handle must first be requested with the OO_LOCKHANDLE operation option. For other operations, this method can be used alone. In any case, the NdbLockHandle object returned by this method cannot be used until the operation has been executed.

Using lock handle methods.  Shared or exclusive locks taken by read operations in a transaction are normally held until the transaction commits or aborts. Such locks can be released before a transaction commits or aborts by requesting a lock handle when defining the read operation. Once the read operation has been executed, an NdbLockHandle can be used to create a new unlock operation (with NdbTransaction::unlock()). When the unlock operation is executed, the row lock placed by the read operation is released.

The steps required to release these locks are listed here:


  • As with other operation types, unlock operations can be batched.

  • Each NdbLockHandle object refers to a lock placed on a row by a single primary key read operation. A single row in the database may have concurrent multiple lock holders (mode LM_Read) and may have multiple lock holders pending (LM_Exclusive), so releasing the claim of one lock holder may not result in a change to the observable lock status of the row.

  • Lock handles are supported for scan lock takeover operations; the lock handle must be requested before the lock takeover is executed.

  • Lock handles and unlock operations are not supported for unique index read operations.


const NdbLockHandle* getLockHandle
    ) const


const NdbLockHandle* getLockHandle

Parameters.  None.

Return value.  Pointer to an NdbLockHandle that can be used by the NdbTransaction methods unlock() and releaseLockHandle().