liveBook · Manning

Isolation

As explained in The Coder Cafe

Isolation is the transaction property that prevents the outcome of one transaction from being affected by interference from other ongoing transactions.

Isolation is the transaction property that keeps one transaction from being affected by another transaction still in progress. An isolation level determines how strictly a database enforces that promise. Isolation is distinct from atomicity: a transaction can apply all its changes or none of them while still encountering interference from concurrent transactions. section 6.5 section 6.8

Two inventory updates

Suppose one employee starts a transaction to add 100 units of a product while another starts a transaction to deduct 50. Under a weak isolation level, the second transaction might see the first employee’s uncommitted update—even if that update is later rolled back. A stronger level prevents that particular interference, but may make concurrent work slower. section 6.8

Isolation levels are distinguished by the anomalies they prevent. Read uncommitted prevents dirty writes; read committed also prevents dirty reads. Stronger levels rule out more anomalies. At the highest level, serializability makes concurrent transactions produce the same result as some sequential execution. section 6.9 section 6.9.9

Anomalies give the choice of level a concrete meaning:

  • A dirty read observes another transaction’s uncommitted write; a dirty write overwrites a value written by another transaction still in progress. section 6.9.9
  • A lost update leaves only one of two competing updates in place. Read skew and write skew describe other ways concurrent work can produce an inconsistent overall result. section 6.9.9 section 6.15
  • A phantom read changes the set of rows matching a query between reads in one transaction because another transaction changes the matching rows. section 6.9.9

A changing query result

A transaction queries students in a course, then queries that group again after another transaction changes its membership. The changed result set is a phantom read. Serializability prevents concurrent changes from altering that transaction’s query result in this way. section 6.9.9

Choose an isolation level according to the anomalies an application can tolerate, not simply by picking the strongest available. Stronger guarantees can reduce throughput or introduce delays; weaker guarantees improve performance at the risk of anomalies. Isolation levels concern transactions within a database. Consistency models address the related but different question of what clients observe across replicas. section 6.8 section 6.7

How The Coder Cafe covers it

How deep it goes
Explains isolation through transaction anomalies and serializability, without detailing database concurrency-control implementations.
Examples
Uses competing inventory updates and changing student-query results to illustrate interference and phantom reads.
What it assumes
Defines transactions and their begin, operation, and commit-or-rollback steps before comparing isolation guarantees.
What you can do after
Evaluate/understand it by matching an application’s tolerance for transaction anomalies to an isolation level’s performance cost.
How it connects
Connects isolation to ACID transactions, serializability, concurrency control, and consistency models across replicas.

Also explained in

Compare how 15 books explain isolation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Coder Cafe. The section links point to the parts of the book it draws on.