8. DatabasesIsolation levels
Isolation levels
Isolation levels are settings that decide how much concurrent transactions can see of each other’s work, trading correctness for speed. At serializable, the strictest, the result is as if transactions ran one at a time. Weaker levels each permit specific glitches: read committed lets the same query return different results within one transaction; repeatable read (in the SQL standard) still allows phantoms, new rows appearing in a re-run range query; and snapshot isolation allows write skew, where two transactions each check a rule, both pass, and their combined writes break it, like two doctors both going off call. Most databases default to a weaker level, so it’s worth knowing which glitches you’ve signed up for.
In this lesson: A two-transaction timeline sandbox: pick a level, run it, and see the anomaly appear or get blocked. Includes the write-skew “doctors on call” scenario.