Scrivio Interview library
ConceptIntermediate6 min read · updated 12 November 2026

What exactly does snapshot isolation guarantee and what does it not? Relate it to PostgreSQL REPEATABLE READ, Oracle SERIALIZABLE and MySQL InnoDB REPEATABLE READ.

Try it yourself

Isolation levels: what a second read sees

Step through two transactions and see exactly when read committed and repeatable read give different answers.

Read this example as text

T1 at read committed

  1. T1 begins. Transaction T1 starts with isolation level READ COMMITTED. The row holds balance 100.
  2. T1 reads the balance. T1 reads 100. Under read committed each statement looks afresh at what is committed when the statement starts.
  3. T2 changes the row. A second transaction, T2, sets the balance to 150 but has not committed. The database keeps both versions: 100 is still the committed one.
  4. T1 reads again, before T2 commits. T1 reads 100 again. Neither level shows another transaction's uncommitted change, so there is no dirty read. T1 does not wait for T2 either.
  5. T2 commits. T2 commits. The committed balance is now 150.
  6. T1 reads a third time. T1 reads 150. The same query, inside one transaction, returned 100 and then 150. This is a non-repeatable read, and read committed allows it.
  7. T1 commits. T1 ends. A transaction that starts now reads 150 at either level.

T1 read 100, 100, then 150: a non-repeatable read.

T1 at repeatable read

  1. T1 begins. Transaction T1 starts with isolation level REPEATABLE READ. The row holds balance 100.
  2. T1 reads the balance. T1 reads 100. Under repeatable read this first read fixes T1's snapshot: T1 will keep seeing the data as it was committed at this moment.
  3. T2 changes the row. A second transaction, T2, sets the balance to 150 but has not committed. The database keeps both versions: 100 is still the committed one.
  4. T1 reads again, before T2 commits. T1 reads 100 again. Neither level shows another transaction's uncommitted change, so there is no dirty read. T1 does not wait for T2 either.
  5. T2 commits. T2 commits. The committed balance is now 150.
  6. T1 reads a third time. T1 still reads 100. Its snapshot was fixed at its first read, so T2's commit is invisible to it. The read is repeatable.
  7. T1 commits. T1 ends. A transaction that starts now reads 150 at either level.

T1 read 100 three times: its reads were repeatable.

What this example leaves out
  • Modelled on PostgreSQL and MySQL InnoDB, where a plain SELECT reads a snapshot and never waits for a writer.
  • SQL Server's default read committed uses locks instead: there, T1's second read would wait for T2 to finish.
  • Only reads are compared. What happens when T1 also writes the row (a lost update, or an error in PostgreSQL) is not modelled.

Snapshot isolation guarantees that every transaction reads from one consistent snapshot taken at its start and that, when two concurrent transactions write the same row, only one of them may commit. That prevents dirty reads, non-repeatable reads, phantoms in reads and lost updates, but it still allows write skew and read-only anomalies, so it is not serializable. PostgreSQL REPEATABLE READ and Oracle SERIALIZABLE are snapshot isolation; MySQL InnoDB REPEATABLE READ is not quite, because its writes act on the latest committed data.

Why this question is asked

Isolation level names are one of the most misleading parts of SQL. The same word, SERIALIZABLE or REPEATABLE READ, means different things in different products, and the behaviour that actually matters is often snapshot isolation under another name. Interviewers ask this to find out whether we know the real guarantees and their gaps, because code that is correct on one database can quietly break on another. In this answer, we will define snapshot isolation precisely, go through what it prevents and what it allows, compare PostgreSQL, Oracle and MySQL, and finish with what applications must do about it.

1What Snapshot Isolation Is

Snapshot isolation has two rules. The first is about reads: a transaction sees the database exactly as it was at one moment, its start, plus its own changes. Other transactions may commit new data while it runs; it will not see any of it. The second is about writes: if two concurrent transactions, meaning transactions whose lifetimes overlap, both write the same row, only one may commit. The other aborts. This is often described as first committer wins; PostgreSQL implements it as first updater wins, because the second writer waits for the first and then fails if the first committed.

Notice what the write rule does not look at. It compares the rows two transactions write, not the rows they read. That single gap explains everything snapshot isolation allows.

2What It Prevents and What It Allows

Because every read comes from the snapshot, a transaction cannot see uncommitted data (no dirty reads), cannot read the same row twice and get different values (no non-repeatable reads), and cannot run the same query twice and see new rows appear (no phantoms in its reads). Because of the write rule, two transactions cannot both read a balance and write a new value for the same row: the second one aborts, so lost updates are prevented.

What it allows is write skew: two transactions read overlapping data, each writes a different row, and together they break a rule, such as two doctors both going off call. It also allows a subtler read-only anomaly, where a transaction that only reads sees a state that no serial order could have produced. Since serializable means 'equivalent to some one-at-a-time order', snapshot isolation is weaker than serializable.

Snapshot isolation at a glance
AnomalyUnder snapshot isolation
Dirty readprevented
Non-repeatable readprevented
Phantom in readsprevented
Lost updateprevented: second writer aborts
Write skewallowed
Read-only anomalyallowed

3PostgreSQL REPEATABLE READ and Oracle SERIALIZABLE

PostgreSQL's REPEATABLE READ is snapshot isolation. The snapshot is taken at the first statement of the transaction, and an attempt to update or delete a row that a concurrent transaction changed and committed fails.

SQL
-- PostgreSQL
BEGIN ISOLATION LEVEL REPEATABLE READ;
SELECT balance FROM account WHERE id = 1; -- 100
-- another session commits balance = 50
UPDATE account SET balance = balance - 10 WHERE id = 1;
-- ERROR: could not serialize access due to concurrent update (SQLSTATE 40001)
-- Oracle, same scenario
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
-- ...
-- ORA-08177: can't serialize access for this transaction

Oracle's level called SERIALIZABLE is also snapshot isolation, not true serializability, and it reports the same conflict as ORA-08177. Oracle has no stronger level. PostgreSQL does: since version 9.1 its SERIALIZABLE adds Serializable Snapshot Isolation, which also tracks reads and aborts transactions that would produce write skew.

4MySQL InnoDB REPEATABLE READ Is Different

InnoDB's REPEATABLE READ gives plain SELECTs a consistent snapshot, so reads look like snapshot isolation. Writes do not. An UPDATE, a DELETE and a locking read (SELECT ... FOR UPDATE or FOR SHARE) operate on the latest committed version of the row, not on the snapshot, and they do not fail when the row changed after the snapshot.

SQL
-- MySQL InnoDB, REPEATABLE READ (its default)
START TRANSACTION;
SELECT balance FROM account WHERE id = 1; -- 100, from the snapshot
-- another session commits balance = 50
SELECT balance FROM account WHERE id = 1; -- 100, still the snapshot
SELECT balance FROM account WHERE id = 1 FOR UPDATE; -- 50, the latest committed row
UPDATE account SET balance = 90 WHERE id = 1; -- app computed 100 - 10; succeeds, 50 is lost
COMMIT;

So the classic lost update, read a value then write an absolute value computed from it, goes through in InnoDB without an error, while PostgreSQL REPEATABLE READ would abort it. That is why InnoDB's REPEATABLE READ is not true snapshot isolation, even though its reads look like it. On the other hand, InnoDB adds gap and next-key locks to locking reads, which PostgreSQL does not have.

5What Applications Must Do

Under snapshot isolation a transaction can be aborted simply because another transaction won a race. That is normal, not a bug, so the application must catch the serialization error (SQLSTATE 40001 in PostgreSQL, ORA-08177 in Oracle) and retry the whole transaction from the start in a new transaction. Retries are cheap only if transactions are short and have no side effects, like sending an email, inside them. For rules that span rows, the application also needs protection beyond snapshot isolation: a constraint, a lock on the rows read, or PostgreSQL's SERIALIZABLE.

6Follow-up questions

Give an example of a read-only anomaly under snapshot isolation.

Take a savings balance X and a checking balance Y, both 0. T2 withdraws 10 from checking: it reads X and Y, sees a total below 10, so it charges a fee of 1 and will write Y = -11. Before T2 commits, T1 deposits 20 into savings, writes X = 20 and commits. Then a read-only report T3 starts and reads X = 20 and Y = 0, and commits. Finally T2 commits Y = -11. The fee says T2 ran before the deposit, but the report saw the deposit without the withdrawal, which says the deposit came first. No serial order fits both, yet without T3 the history would have been fine. PostgreSQL SERIALIZABLE catches this.

Why is the write rule enough to stop lost updates but not write skew?

A lost update always means two transactions writing the same row, which the rule detects. Write skew writes different rows, so the rule sees no overlap.

Is PostgreSQL READ COMMITTED snapshot isolation?

No. Each statement gets its own snapshot, so a transaction can see different data from one statement to the next, and there is no write-conflict abort; an UPDATE simply re-reads the latest version.

7Conclusion

In this answer, we saw that snapshot isolation means reading from one consistent snapshot and aborting one of two concurrent writers of the same row. It prevents dirty reads, non-repeatable reads, phantoms in reads and lost updates, but allows write skew and read-only anomalies, so it is not serializable. PostgreSQL REPEATABLE READ and Oracle SERIALIZABLE are snapshot isolation and raise 40001 and ORA-08177; InnoDB REPEATABLE READ snapshots only plain reads, so lost updates can slip through. Applications must retry on serialization errors.

What to say in the interviewAbout 70 seconds aloud

Open with

Snapshot isolation gives two guarantees. Every transaction reads from one consistent snapshot taken at its start, and if two concurrent transactions write the same row, only one can commit; the other aborts.

Then, if they want more

So it prevents dirty reads, non-repeatable reads, phantoms in what it reads, and lost updates. What it doesn't do is look at reads when checking conflicts, so it allows write skew, where two transactions read the same data and write different rows, and also a read-only anomaly where a reporting transaction sees a state no serial order could produce.

So it's not serializable. PostgreSQL's REPEATABLE READ is snapshot isolation, and the losing writer gets could not serialize access, SQLSTATE 40001. Oracle's SERIALIZABLE is really snapshot isolation too, and it raises ORA-08177.

MySQL InnoDB's REPEATABLE READ is different: plain selects use a snapshot, but updates and locking reads work on the latest committed row and don't fail, so a read-then-write can lose an update. That's why I wouldn't call it true snapshot isolation. In all of them, the application has to be ready to retry the whole transaction on a serialization error.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What exactly does snapshot isolation guarantee and what does it not? Relate it to...": https://scrivio-interview-library.netlify.app/databases/acid-and-isolation/9f8c0d2910/