Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

Session-Wide Lock Modes

The table below lists the lock modes that are to be used with the session-wide record locking function ctdbLock().

c-treeDB API Lock Modes

c-treeDB API .NET
Lock Modes


Explanation

CTLOCK_FREE

FREE_LOCK

Turn off session-wide record locking. Free all automatically-acquired locks (with certain exceptions, see below).

CTLOCK_READ

READ_LOCK

Non-blocking read locks. If the lock cannot be acquired an error is returned.

CTLOCK_READ_BLOCK

READ_BLOCK_LOCK

Blocking read lock. The thread will block until the lock can be acquired.

CTLOCK_WRITE

WRITE_LOCK

Non-blocking write lock. If the lock cannot be acquired an error is returned.

CTLOCK_WRITE_BLOCK

WRITE_BLOCK_LOCK

Blocking write lock. The thread will block until the lock can be acquired.

CTLOCK_RESET

RESET_LOCK

Equivalent to calling Lock with CTLOCK_FREE followed by Lock() with CTLOCK_WRITE. This releases currently-held record locks (with certain exceptions, see below).

CTLOCK_SUSPEND

SUSPEND_LOCK

Temporarily suspend session-wide record locking. While locking is suspended, new record reads, writes, and deletes will not be automatically locked. Existing record locks remain in place, though.

CTLOCK_RESTORE
_READ

RESTORE_READ_LOCK

To be used after a call to Lock with the CTLOCK_SUSPEND mode. This lock mode restores the lock mode as READ.

CTLOCK_RESTORE
_READ_BLOCK

RESTORE_READ

_BLOCK_LOCK

To be used after a call to Lock with the CTLOCK_SUSPEND mode. This lock mode restores the lock mode as READ_BLOCK.

CTLOCK_RESTORE
_WRITE

RESTORE_WRITE_LOCK

To be used after a call to Lock with the CTLOCK_SUSPEND mode. This lock mode restores the lock mode as WRITE.

CTLOCK_RESTORE
_WRITE_BLOCK

RESTORE_WRITE

_BLOCK_LOCK

To be used after a call to Lock with the CTLOCK_SUSPEND mode. This lock mode restores the lock mode as WRITE_BLOCK.

CTLOCK_RESTORE
_PREVIOUS

 

To be used after a call to Lock with the CTLOCK_SUSPEND mode. This lock mode restores the same lock mode that was valid before suspending the lock.

c-treeDB API .NET Lock Modes are defined in the LOCK_MODE enum.

Notes:

  • If you wish to turn session-wide locking off and release the record locks, use FREE.
  • If you wish to turn session-wide locking off and keep the record locks, use SUSPEND.
  • If you wish to turn session-wide locking back on (so new record reads, writes, and deletes get automatically locked), while keeping the record locks that existed before the SUSPEND, use one of the RESTORE modes.
  • If you wish to turn session-wide record locking back on and release the existing record locks, use RESET.

The modes listed in this table (except for the “RESET” and “_RESTORE_” modes) are also returned by the ctdbGetLockMode() function to show the current state of the session-wide locking system.

TOCIndex