Tamino XML Server Version 9.7
 —  Transactions Guide  —

Deadlocks and Deadlock Prevention

This section discusses the following topics concerning deadlocks:


Deadlock Example

Deadlock situations can occur when concurrent transactions work on the same set of documents and attempt to set locks on these documents in a particular order. A typical deadlock situation occurs if two or more transactions are each waiting for a lock to be released held by one of the other transactions. If this occurs, Tamino usually detects this and chooses one transaction for rollback thus releasing all the locks it holds and resolving the deadlock. Finally, a transaction which is in a deadlock situation will receive a timeout on basis of the transaction timeout parameter, but normally a deadlock situation should already have been recognized by Tamino before the transaction is timed out. But also in a timeout situation, one transaction is rolled back releasing its locks and therefore resolving the deadlock situation.

Deadlock Example 1

  1. Transaction 1 reads document 1 (setting an S lock)

  2. Transaction 1 updates document 1 (setting an X lock)

  3. Transaction 2 reads document 2 (setting an S lock)

  4. Transaction 2 updates document 2 (setting an X lock)

  5. Transaction 1 reads document 2 (attempting to set an S lock, resulting in waiting for the release of the X lock set by transaction 2)

  6. Transaction 2 reads document 1 (attempting to set an S lock, resulting in waiting for the release of the X lock set by transaction 1)

Now both transactions wait for each other and a deadlock situation has arisen.

Deadlock Example 2

  1. Transaction 1 reads document 1 (setting an S lock)

  2. Transaction 2 reads document 1 (setting an S lock)

  3. Transaction 1 updates document 1 (attempting to get an X lock)

  4. Transaction 2 updates document 1 (attempting to get an X lock)

Now also a deadlock situation has arisen.

Top of page

Deadlock Prevention

Although deadlock situations are detected by Tamino, and do normally not lead to excessive wait times, a deadlock still results in a rollback of a transaction. It is therefore better to avoid deadlock situations as much as possible. The most well known technique to avoid deadlocks is to determine a fixed order in which concurrent transactions acquire their locks.

Top of page