Lock Manager Support for Detached Transactions

Transactions may be detached from their original threads, and have no associated spid. Moreover, multiple threads with different spid values must be able to share the same transaction locks to perform the work of a distributed transaction.

The SAP ASE lock manager uses a unique lock owner ID, rather than a spid, to identify transaction locks. The lock owner ID is independent from the spid that created the transaction, and it persists even when the transaction is detached from a thread. Lock owner IDs provide a way to support transactional locks when transactions have no associated threads, or when a new thread is attached to the transaction.

The lock owner ID is stored in the loid column of syslocks. You can determine the loid value of a transaction by examining sp_lock or sp_transactions output.

Examining the spid and loid columns from sp_transactions output provides information about a transaction and its thread of control. A spid value of zero indicates that the transaction is detached from its thread of control. Non-zero spid values indicate that the thread of control is currently attached to the transaction.

If the loid value in sp_transactions output is even, then a local transaction owns the lock. Odd loid values indicate that an external transaction owns the lock.