I Help You
Databases

Deadlock (Database)

A deadlock happens when two or more transactions each hold a lock the other needs, so none of them can continue. For example, transaction A locks row 1 and waits for row 2, while transaction B locks row 2 and waits for row 1.

Databases detect deadlocks automatically and break them by rolling back one transaction (the victim), which the application should retry. Deadlocks are made less likely by keeping transactions short, accessing tables and rows in the same order everywhere, and using suitable indexes so fewer rows are locked.