Avoid Deadlocks in Transfers
Two sessions transfer money between accounts 1 and 2 in opposite directions at the same time and deadlock. Show how to lock the rows so that a deadlock cannot occur.
Table schema
Accounts(id INT PRIMARY KEY, balance INT)Sample data
Session A: transfer 1 -> 2; Session B: transfer 2 -> 1
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.