Locking

Locks have three basic attributes: object, mode and duration. Lockable objects include records and tables. Lock modes are shared and exclusive. Duration refers to the length of time a lock is held. Duration is dependent on the type of object locked, the lock mode, and the isolation level currently established.

The XDB Server supports automatic record level locking (R locks). Programs never have to request record level locks explicitly. The server can lock one record at a time, rather than a minimum of a page or block of data, which might result in reduced concurrency among users. In addition to record level locking, the XDB Server provides table locking. Table level exclusive (TX) and table level shared (TS) locks are acquired by using the LOCK command.

The server provides both shared and exclusive locks. In general, shared locks (S locks) are placed on an object when the object will be read only (not updated). This type of lock prevents any other transaction from changing the locked record for the duration of the lock. Other transactions may still read the locked record. The release of shared locks depends on the type and isolation level of the lock.

Exclusive locks (X locks) must be acquired before an object can be changed. When an exclusive lock is held on an object, no other transaction can reference the locked object. Exclusive locks are generally held until the end of the transaction that owns them (or until the transaction issues a COMMIT or ROLLBACK command).

Intentional table level locks will also be automatically acquired by the server. Before any shared record lock is granted, the server first places an intentional share lock (IS lock) on the table. Similarly, the server places an intentional exclusive lock (IX lock) on the table before an exclusive record lock is granted.