Collection Contents Index How Adaptive Server Anywhere implements locking Savepoints within transactions pdf/chap15.pdf

User's Guide
   PART 2. Relational Database Concepts
     CHAPTER 15. Using Transactions and Locks       

Locking conflicts


When a transaction attempts to acquire a lock on a row, but is forbidden by a lock held by another transaction, a locking conflict arises and the progress of the transaction attempting to acquire the lock is impeded or blocked.

For Info     The next section, The BLOCKING option," describes transaction blocking.

Transaction blocking and deadlock describes deadlock, which occurs when two or more transactions are blocked by each other in such a way that none can proceed.

Top of page  The BLOCKING option

If two simultaneously transactions have each acquired a read lock on a single row, the behavior when one of them attempts to modify that row depends on the database setting BLOCKING. To modify the row, that transaction must acquire a write lock, yet it cannot do so while the other transaction holds a lock on the row.

When BLOCKING is set to OFF, the transaction terminates instead of waiting and any changes it has made are rolled back. In this event, try executing the transaction again, later.

Blocking is more likely to occur at higher isolation levels because more locking and more checking is done. Higher isolation levels usually provides less concurrency. How much less depends on the individual natures of the concurrent transactions.

For information about the BLOCKING option, see BLOCKING option.

Top of page  Transaction blocking and deadlock

Transaction blocking can lead to deadlock, where a set of transactions arrive at a state where none of them can proceed.

Reasons for deadlocks 

A deadlock can arise for two reasons:

Adaptive Server Anywhere automatically cancels the last transaction that became blocked (eliminating the deadlock situation), and returns an error to that transaction indicating which form of deadlock occurred.

Determining who is blocked 

You can use the sa_conn_info system procedure to determine which connections are blocked on which other connections. This procedure returns a result set consisting of a row for each connection. One column of the result set lists whether the connection is blocked, and if so which other connection it is blocked on.

For Info     For more information, see sa_conn_info system procedure

Top of page  

Collection Contents Index How Adaptive Server Anywhere implements locking Savepoints within transactions pdf/chap15.pdf