# 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.

In the following figure, `derby.locks.deadlockTimeout` is set to 30 seconds, while `derby.locks.waitTimeout` has no limit.

Figure 1. Configuration with deadlock checking after 30 seconds and no lock wait timeouts

In the following figure, `derby.locks.deadlockTimeout` is set to 60 seconds, while `derby.locks.waitTimeout` is set to 90 seconds.

Figure 2. Configuration with deadlock checking after 60 seconds and lock wait timeout at 90 seconds

In the following figure, `derby.locks.deadlockTimeout` is set to 60 seconds, while `derby.locks.waitTimeout` is set to 50 seconds, lower than the deadlock timeout limit.

Figure 3. Configuration with no deadlock checking and a 50-second lock wait timeout
Parent topic: Deadlocks
Related concepts
Avoiding deadlocks
Deadlock detection
Lock wait timeouts
Debugging deadlocks
Programming applications to handle deadlocks