LESSON 14 / 24·2 min readAdvanced

What are isolation levels and read anomalies?

01 Understand02 Recall03 Prepare

Understand the concept

Isolation defines how one transaction can observe and interfere with concurrent transactions. Different levels allow different anomalies to balance correctness, concurrency and retry cost. PostgreSQL uses snapshots under MVCC, but even a stable snapshot does not automatically make every business decision safe against concurrent writes.

Important ideas

  • Dirty read: uncommitted data; non-repeatable read: a row changes; phantom: matching rows change.
  • PostgreSQL Read Committed uses a new snapshot per statement; Repeatable Read uses a stable transaction snapshot.
  • Serializable prevents serialization anomalies, but applications must retry failed transactions; PostgreSQL treats Read Uncommitted as Read Committed.

Reference: PostgreSQL isolation.

  • Repeatable Read can still allow write-skew anomalies; Serializable detects incompatible concurrent histories and may abort a transaction.

Comparison — PostgreSQL:

LevelTypical read viewImportant limitation
Read CommittedNew snapshot per statementA later read may see a changed result
Repeatable ReadStable transaction snapshot, plus own writesSome cross-row business anomalies remain
SerializableSuccessful transactions fit a serial orderConflicting work may need a full retry
PAUSE & RECALL

Can you explain it without the notes?

What are isolation levels and read anomalies?

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

Isolation defines how one transaction can observe and interfere with concurrent transactions. Different levels allow different anomalies to balance correctness, concurrency and retry cost. PostgreSQL uses snapshots under MVCC, but even a stable snapshot does not automatically make every business decision safe against concurrent writes.

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

  • Explain a real anomaly and the chosen protection, then mention whole-transaction retries where the database can reject conflicting work.
Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: Optimistic vs pessimistic locking?

Adapted from 05_SQL_POSTGRESQL.md · “What are isolation levels and read anomalies?”. Examples are study fragments; framework behavior can depend on your version.