Database Transaction Deadlock Simulator

Step through time to watch two concurrent database transactions acquire row-level locks, enter a circular wait, and trigger a DBMS rollback.

Step 0: Transactions initialized. Click "Execute Next Time Step" to begin executing SQL statements.

Transaction A (Transfer $100)

BEGIN TRANSACTION;
UPDATE Accounts SET bal = bal - 100 WHERE id = 101;
UPDATE Accounts SET bal = bal + 100 WHERE id = 102;
COMMIT;

Database: Accounts Table

Account ID Balance Row Lock Status
101 (Alice) $500 Unlocked
102 (Bob) $500 Unlocked

Transaction B (Transfer $50)

BEGIN TRANSACTION;
UPDATE Accounts SET bal = bal - 50 WHERE id = 102;
UPDATE Accounts SET bal = bal + 50 WHERE id = 101;
COMMIT;