Interview Question

What is deadlock?

A deadlock is a circular lock wait resolved by aborting a participant.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

A deadlock occurs when transactions wait on one another in a cycle and none can proceed. • Database systems detect the cycle and abort one transaction. • Applications should handle the resulting error and may retry safely. • Consistent lock ordering reduces deadlock risk.

💡 SQL Example

UPDATE accounts SET balance = balance - 10 WHERE account_id = 1;

Result

One transaction may be aborted if a wait cycle forms

⚡ Quick Revision

A deadlock is a circular lock wait resolved by aborting a participant.