Transaction A reads a row, then Transaction B updates and commits that row before A finishes. When A reads the same row again, it gets the updated value. Which anomaly is this?
ADirty read
BNon-repeatable read
CPhantom read
DLost update
A non-repeatable read occurs when a transaction reads the same row twice and gets different values because another transaction committed an update in between. A dirty read would involve reading B's changes *before* B commits. A phantom read involves new rows appearing, not changed existing rows.
READ COMMITTED only prevents dirty reads (reading uncommitted data). It still allows non-repeatable reads because each statement sees a fresh snapshot, so the same row can return different values in two reads within the same transaction. REPEATABLE READ is required to prevent this anomaly.
Question 3 Short Answer
How does MVCC allow readers and writers to operate concurrently without blocking each other?
Think about your answer, then reveal below.
Model answer: MVCC keeps multiple versions of each row. Readers see a consistent snapshot from the start of their transaction (an older version), while writers create new row versions. Because reads never access the same version a writer is modifying, neither blocks the other.
This contrasts with lock-based concurrency where readers and writers compete for the same lock. MVCC's snapshot isolation means long-running read queries (like analytics) do not block writes, which is critical for throughput in production systems like PostgreSQL.