Transactions and Isolation
What a transaction really promises, and what each isolation level still lets through. Walk through dirty reads, lost updates, and write skew using money movement and seat booking, then learn how to choose a level on purpose.
Lessons
- 01Know what a transaction promisesA transaction makes a group of writes succeed or fail together, but the database can only protect the rules it has been told about.
- 02Hide unfinished workRead committed, a common default, stops transactions from seeing or overwriting each other’s unfinished writes.
- 03Read from one point in timeSnapshot isolation gives each transaction a frozen view of committed data, built by keeping several versions of each row.
- 04Stop writers overwriting each otherWhen two transactions read a value and write back something computed from it, one change can silently vanish.
- 05Catch conflicts across different rowsTwo transactions can each check a rule, write different rows, and together break it, with no conflict for the database to notice.
- 06Choose how to serializeSerializable isolation makes concurrent transactions behave as if they ran one at a time, and there are three main ways to build it.