# Does .snapshot() provide Snapshot Level Isolation?

**URL:** <https://forums.foundationdb.org/t/does-snapshot-provide-snapshot-level-isolation/301>\
**Category:** Using FoundationDB\
**Created:** [April 29, 2018, 5:48am UTC](https://forums.foundationdb.org/t/does-snapshot-provide-snapshot-level-isolation/301 "2018-04-29T05:48:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://forums.foundationdb.org/u/gaurav)\
**Post date:** [April 29, 2018, 5:48am UTC](https://forums.foundationdb.org/t/does-snapshot-provide-snapshot-level-isolation/301/1 "2018-04-29T05:48:23Z")

</div>

Hi there,

I wanted to confirm that .snapshot() on a transaction provides a true [snapshot level isolation](https://en.wikipedia.org/wiki/Snapshot_isolation) for get()/getRange() calls? The documentation simply says that this “reduces” conflicts but does not explicitly states the guarantees.

More precisely, if at some time _t1_, keys _a_ and _b_ have values _1_ and _2_ respectively, and a snapshot read operation was started at _t1_ on these keys. Concurrently, two other write transactions modified these keys as follows: _tr2 (a=10, b=11)_ and _tr3 (a=20, b=21)_.

If I understand correctly, under snapshot isolation, possible read value combinations should be:  
i) a=1, b=2 OR  
ii) a=10, b=11 OR  
iii) a=20, b=21

Can I expect that only one of these possible combination of values will be returned? Or is there a possibility to get back value pairs like _\<a=1, b=10\>_ or _\<a=1, b=21\>_ etc.?

–  
thanks,  
gaurav

---

<div class="post-metadata">

**Author:** ![alexmiller](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/alexmiller/32/326_2.png) [@alexmiller](https://forums.foundationdb.org/u/alexmiller)\
**Post date:** [April 29, 2018, 7:52am UTC](https://forums.foundationdb.org/t/does-snapshot-provide-snapshot-level-isolation/301/2 "2018-04-29T07:52:44Z")

</div>

If I understand your outlined case correctly, only (i) is possible, because tr2 and tr3 would commit at a version \>t1. But yes, `snapshot()` gives you a consistent view of the database at t1.

The documentation, is attempting to state that a commit of tr2 or tr3 won’t cause tr1 to abort, because snapshot reads don’t manifest as conflicts to the transaction resolver. So if tr1 does a snapshot read of `a` and `b` at t1, writes it to `sum` and commits concurrently with tr2 and tr3, it’s valid for FDB to commit tr2, followed by tr3, followed by tr1, and the ending database state would be `a=20, b=21, sum=3`.

---

<div class="post-metadata">

**Author:** ![gaurav](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@gaurav](https://forums.foundationdb.org/u/gaurav)\
**Post date:** [April 29, 2018, 11:02am UTC](https://forums.foundationdb.org/t/does-snapshot-provide-snapshot-level-isolation/301/3 "2018-04-29T11:02:05Z")

</div>

Thanks for clarifying it.  
Yes, FDB’s external consistency should guarantee outcome (i); whereas with a DB providing only Snapshot Isolation guarantee any of (i), (ii) or (iii) might have been a valid outcome.
