Skip to content
StackDecode
System Design
5. Advanced Database ArchitectureAnimated

Snapshot Isolation

Each transaction sees a consistent snapshot.

The idea

Reads see the data as of transaction start, avoiding dirty and non-repeatable reads.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

ReaderDatabaseWriterBEGIN (snapshot at t=10)
  • current message
  • earlier
  • failure or attack

The reader starts and sees the database as of time 10.

step:
1/6
from:
Reader
to:
Database
1/6

Time runs downward. Solid arrows are requests, dashed arrows are replies.

Step by step

  1. 1Take a snapshot at begin
  2. 2Read from it
  3. 3Write new versions
  4. 4Conflicts abort at commit

Where it is used

PostgreSQL repeatable read.

Watch out for

Write skew is still possible.

Related