Transactions
28 bites tagged Transactions — interview questions with model answers, and 60-second explainers.
Database Deadlock: The Two-Way Standoff
A deadlock is a 'Mexican standoff' where two transactions can't finish because each is waiting for a resource the other has locked. This happens in systems with concurrent writes. The database will kill one transaction, forcing your app to handle the retry.
Two-Phase Locking (2PL): Preventing Database Race Conditions
2PL is a database's pessimistic strategy for safe concurrency. A transaction acquires all necessary locks before releasing any, ensuring operations don't clash. It's used to guarantee consistency.
Transaction Isolation Levels: The Concurrency vs. Correctness Dial
Think of isolation levels as a database dial trading transaction correctness for raw concurrency. You tune this when balancing performance against the risk of data anomalies. The footgun: the default level isn't always the safest; you must know its guarantees.
ACID: The Four Guarantees of Database Transactions
ACID is a contract for database transactions: all-or-nothing guarantees for data validity, even during crashes. It's critical for relational databases in finance or e-commerce. The footgun is assuming all databases offer this; many NoSQL systems don't.
Get Transactions bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.