-
-
Save galderz/9ba22e47116906a750d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
With RC and no WSC: | |
tm(0).begin(); | |
cache(0).put(k, "v1"); | |
final Transaction tx1 = tm(0).suspend(); | |
//another tx working on the same keys | |
tm(0).begin(); | |
cache(0).put(k, "v2"); | |
tm(0).commit(); | |
assert cache(0).get(k).equals("v2"); | |
assert cache(1).get(k).equals("v2"); | |
tm(0).resume(tx1); | |
tm(0).commit(); | |
assert cache(0).get(k).equals("v1"); | |
assert cache(1).get(k).equals("v1"); | |
With RR and WSC: | |
tm(0).begin(); | |
cache(0).put(k, "v1"); | |
final Transaction tx1 = tm(0).suspend(); | |
//another tx working on the same keys | |
tm(0).begin(); | |
cache(0).put(k, "v2"); | |
tm(0).commit(); | |
assert cache(0).get(k).equals("v2"); | |
assert cache(1).get(k).equals("v2"); | |
tm(0).resume(tx1); | |
try { | |
tm(0).commit(); | |
fail("Should have rolledback with write skew failure"); | |
} catch (RollbackException e) { | |
// Write skew fails | |
assert cache(0).get(k).equals("v2"); | |
assert cache(1).get(k).equals("v2"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment