A deadlock occurs when two (or more) transactions each hold a lock the other needs, so neither can proceed — they're stuck waiting for each other forever. Databases detect deadlocks and resolve them by aborting one transaction (the "victim"), which must retry. Understanding the causes and prevention is important for concurrent applications.
Paano deadlock dumadating
Transaction A: locks row 1, then wants row 2
Transaction B: locks row 2, then wants row 1
→ A waits for B (to release row 2), B waits for A (to release row 1) → DEADLOCK
Neither can proceed; they're waiting on each other in a cycle.
; ;
accounts .. id; accounts .. id;
accounts .. id; accounts .. id;
