Configuring deadlock detection and lock wait timeouts

You configure the amount of time a transaction waits before Derby does any deadlock checking with the derby.locks.deadlockTimeout property.

You configure the amount of time a transaction waits before timing out with the derby.locks.waitTimeout property. When configuring your database or system, you should consider these properties together. For example, in order for any deadlock checking to occur, the derby.locks.deadlockTimeout property must be set to a value lower than the derby.locks.waitTimeout property. If it is set to a value equal to or higher than the derby.locks.waitTimeout, the transaction times out before Derby does any deadlock checking.

By default, derby.locks.waitTimeout is set to 60 seconds. -1 is the equivalent of no wait timeout. This means that transactions never time out, although Derby can choose a transaction as a deadlock victim.

Figure 1. One possible configuration: deadlock checking occurs when a transaction has waited 30 seconds; no lock wait timeouts occur.
This figure shows a configuration
where deadlock checking occurs when a transaction has waited 30 seconds. No
lock wait timeouts occur.
Figure 2. Another typical configuration: deadlock checking occurs after a transaction has waited 60 seconds for a lock; after 90 seconds, the transaction times out and is rolled back.
This figure shows a configuration
where deadlock checking occurs after a transaction has waited 60 seconds for
a lock. After 90 seconds, the transaction times out and is rolled back.
Figure 3. A configuration in which no deadlock checking occurs: transactions time out after they have waited 50 seconds. No deadlock checking occurs.
This figure shows a configuration
where no deadlock checking occurs. The transactions time out after they have
waited 50 seconds. No deadlock checking occurs.
Related concepts
Avoiding deadlocks
Deadlock detection
Lock wait timeouts
Debugging Deadlocks
Programming applications to handle deadlocks