Database Deadlock | Database Interview | Skill-Lync Resources
Medium Database Systems Transactions & ACID

What is a database deadlock and how is it handled?

Answer

Deadlock occurs when two transactions wait for each other's locks indefinitely. Example: T1 locks row A, wants B; T2 locks row B, wants A. Detection: wait-for graph with cycles. Resolution: one transaction is chosen as victim and rolled back (based on cost, age, or priority). Prevention: acquire all locks upfront, order lock acquisition consistently, use shorter transactions, lower isolation levels. Most databases detect and resolve automatically.

Master These Concepts with IIT Certification
IIT Certified

Master These Concepts with IIT Certification

175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.

Relevant for Roles

Software Engineer Backend Developer Database Administrator