Deadlocks

In a database, a deadlock is a situation in which two or more transactions are waiting for one another to give up locks.

For example, Transaction A might hold a lock on some rows in the Accounts table and needs to update some rows in the Orders table to finish. Transaction B holds locks on those very rows in the Orders table but needs to update the rows in the Accounts table held by Transaction A. Transaction A cannot complete its transaction because of the lock on Orders. Transaction B cannot complete its transaction because of the lock on Accounts. All activity comes to a halt and remains at a standstill forever unless the DBMS detects the deadlock and aborts one of the transactions.

Figure 1. A deadlock where two transactions are waiting for one another to give up locks.
This figure depicts a deadlock.
Transaction A has a lock on the Accounts table and needs a lock on the Orders
table to finish the transaction. Transaction B has a lock on the Orders table
and needs a lock on the Accounts table to finish the transaction.
Related concepts
Isolation levels and concurrency
Configuring isolation levels
Lock granularity
Types and scope of locks in Derby systems