Algorithm Search⌘K

Definitionadvanced

Adya's generalized isolation levels

Also called direct serialization graph, DSG isolation levels, portable isolation levels, PL-1 to PL-3.

Isolation levels defined by the cycles they forbid in a graph of dependencies between committed transactions, so that locking, optimistic and multiversion systems can all meet them.

Atul Adya's thesis (1999), and the paper of Adya, Liskov and O'Neil (2000), define isolation levels by the shapes of cycles in the direct serialization graph (DSG) of a history, a graph on the committed transactions with an arc for each write dependency, read dependency and anti-dependency. The levels of Berenson et al. (1995) forbid patterns of operations such as "a read of data that has not committed yet", and in effect assume a locking implementation; optimistic and multiversion systems that produce correct histories by other means fail those definitions. Adya's levels speak only about committed transactions and the versions they read and install, so any implementation can meet them. The graph is the multiversion serialization graph with the version order given in the history, and its cycles are the transaction anomalies. The four portable levels PL-1, PL-2, PL-2.99 and PL-3 match read uncommitted, read committed, repeatable read and serializable; the thesis adds PL-2+, the weakest level with consistent reads, and PL-SI, a definition of snapshot isolation without timestamps.

Definition

Histories. A history HH consists of the reads, writes, commits and aborts of the transactions, and a version order ≪\ll: for each object, a total order on the versions installed by committed transactions. Each write wi(xi)w_i(x_i) makes a version xix_i; a read rj(xi)r_j(x_i) names the version it returns; a predicate read rj(P:V)r_j(P : V) names the predicate PP and the set VV of versions, one per object, from which its matches were computed. A version of xx changes the matches of PP if xx matches PP in that version and not in the version before it in ≪\ll, or the other way round.

Dependencies. For committed Ti≠TjT_i \ne T_j:

  • Ti→wwTjT_i \xrightarrow{ww} T_j (directly write-depends) if TiT_i installs xix_i and TjT_j installs the next version of xx after xix_i in ≪\ll.
  • Ti→wrTjT_i \xrightarrow{wr} T_j (directly read-depends) if TjT_j reads xix_i (an item read dependency), or if a predicate read of TjT_j uses a version of xx equal to or later than a version xix_i that changes the matches of PP (a predicate read dependency).
  • Ti→rwTjT_i \xrightarrow{rw} T_j (directly anti-depends) if TiT_i reads a version xkx_k and TjT_j installs the next version of xx after xkx_k (an item anti-dependency), or if TjT_j installs a version that changes the matches of a predicate read of TiT_i and comes after the version that read used (a predicate anti-dependency).

DSG. DSG(H)DSG(H) has a node for each committed transaction and an arc for each of these dependencies.

Phenomena.

  • G0 (write cycles): DSG(H)DSG(H) has a cycle of ww arcs only.
  • G1a (aborted reads): a committed transaction reads a version written by a transaction that aborts.
  • G1b (intermediate reads): a committed transaction reads a version of xx written by TiT_i that is not the last version of xx that TiT_i writes.
  • G1c (circular information flow): DSG(H)DSG(H) has a cycle of ww and wr arcs only.
  • G1 is G1a, G1b or G1c.
  • G-single (single anti-dependency cycles): DSG(H)DSG(H) has a cycle with exactly one rw arc.
  • G2-item (item anti-dependency cycles): DSG(H)DSG(H) has a cycle with at least one item rw arc.
  • G2 (anti-dependency cycles): DSG(H)DSG(H) has a cycle with at least one rw arc.

Levels. A history is at the level if it shows none of the listed phenomena.

level forbids corresponds to
PL-1 G0 read uncommitted
PL-2 G1 read committed
PL-2+ G1, G-single consistent reads, no lost updates
PL-2.99 G1, G2-item repeatable read
PL-3 G1, G2 serializable
PL-SI G1, G-SI snapshot isolation

A history without G1 and G2 has an acyclic DSG, and is then serializable: any topological sort is a serial order, as in the MVSG theorem.

PL-SI. For snapshot isolation each committed transaction also has a start point and a commit point in one time order. The start-ordered serialization graph SSG(H)SSG(H) is DSG(H)DSG(H) plus a start-dependency arc Ti→sTjT_i \xrightarrow{s} T_j whenever TiT_i commits before TjT_j starts. G-SIa (interference) holds if SSG(H)SSG(H) has a ww or wr arc from TiT_i to TjT_j but no start-dependency arc from TiT_i to TjT_j: TjT_j saw or overwrote the effect of a transaction that had not committed when TjT_j started. G-SIb (missed effects) holds if SSG(H)SSG(H) has a cycle with exactly one rw arc. G-SI is G-SIa or G-SIb.

Examples and non-examples

A serializable history that the broad P1 forbids. w1(x1) r2(x1) c1 c2w_1(x_1)\, r_2(x_1)\, c_1\, c_2. T2T_2 reads data before T1T_1 commits, so the broad dirty read P1 of Berenson et al. rejects it at read committed. Here T1T_1 commits and the DSG has the single arc T1→wrT2T_1 \xrightarrow{wr} T_2, so the history is PL-3. An optimistic system that lets T2T_2 read early and makes it wait for T1T_1 at commit produces exactly this.

A serializable history that the broad P2 forbids. r1(x0) w2(x2) c2 c1r_1(x_0)\, w_2(x_2)\, c_2\, c_1. T2T_2 writes an item that T1T_1 read before T1T_1 ends, which is the broad fuzzy read P2. The DSG has one arc T1→rwT2T_1 \xrightarrow{rw} T_2 and no cycle, so the history is PL-3, with the serial order T1 T2T_1\, T_2. A multiversion system can give it at serializable without making T2T_2 wait.

The lost update is PL-2 but not PL-2+. r1(x0) r2(x0) w2(x2) c2 w1(x1) c1r_1(x_0)\, r_2(x_0)\, w_2(x_2)\, c_2\, w_1(x_1)\, c_1 with x0≪x2≪x1x_0 \ll x_2 \ll x_1. The arcs are T1→rwT2T_1 \xrightarrow{rw} T_2 (T1T_1 read x0x_0, and T2T_2 installs the next version) and T2→wwT1T_2 \xrightarrow{ww} T_1. The cycle has one rw arc: G-single and G2-item, but no G1.

Write skew is PL-2+ and PL-SI but not PL-2.99. r1(x0) r1(y0) r2(x0) r2(y0) w1(x1) w2(y2) c1 c2r_1(x_0)\, r_1(y_0)\, r_2(x_0)\, r_2(y_0)\, w_1(x_1)\, w_2(y_2)\, c_1\, c_2. The cycle T1→rwT2→rwT1T_1 \xrightarrow{rw} T_2 \xrightarrow{rw} T_1 has two item rw arcs. So it is G2-item but not G-single. With both transactions concurrent, the SSG has no start arcs and no ww or wr arcs between them, and no cycle with one rw arc, so it is PL-SI: this is the write skew of snapshot isolation.

A phantom that PL-2.99 allows. T1T_1 reads the employees of a department by a predicate PP, and then the stored count zz. T2T_2 inserts a new employee yy in that department, updates zz and commits before T1T_1 reads zz. The predicate read of T1T_1 used the version of yy before the insert, so T1→rwT2T_1 \xrightarrow{rw} T_2 is a predicate anti-dependency, and T2→wrT1T_2 \xrightarrow{wr} T_1 on zz. The cycle has one rw arc, which is a predicate arc: the history is not G2-item, so PL-2.99 allows it, but it is G2 and G-single, so PL-3 and PL-2+ forbid it. This is H3 of Berenson et al.

A serializable history that is not PL-SI. T2T_2 starts, T1T_1 writes x1x_1 and commits, then T2T_2 reads x1x_1 and commits. The serial order T1 T2T_1\, T_2 explains it, so it is PL-3. But T1→wrT2T_1 \xrightarrow{wr} T_2 has no start-dependency arc, since T1T_1 committed after T2T_2 started: G-SIa. A snapshot taken at the start of T2T_2 could not contain x1x_1.

  • How the levels relate. PL-1 is weaker than PL-2, and PL-3 is stronger than all others except PL-SI. PL-2+ and PL-2.99 are incomparable: write skew separates them one way and the predicate phantom above the other. PL-SI is stronger than PL-2+, since every DSG cycle with one rw arc is an SSG cycle with one rw arc, and it is incomparable with PL-3 and with PL-2.99, as write skew and the last example show.
  • Isolation levels gives the levels of SQL and of Berenson et al., and the correspondence with locking.
  • Multiversion serializability is the setting: the DSG is the multiversion serialization graph for the version order of the history, with its arcs split by kind.
  • The dangerous structure theorem is a statement about DSG cycles under snapshot isolation: every cycle has two rw arcs in a row between concurrent transactions.
  • Highly available transactions and consistency models use these phenomena to classify which levels a system can give while it stays available during network partitions.

References

  1. Atul Adya, Weak consistency, a generalized theory and optimistic implementations for distributed transactions, PhD thesis, MIT, 1999, the chapters on histories with version orders, the direct serialization graph, the phenomena G0 to G2 and G-single, the levels PL-1 to PL-3 with PL-2+ and PL-2.99, and the start-ordered serialization graph with PL-SI; chapter level only
  2. Atul Adya, Barbara Liskov and Patrick O'Neil, Generalized isolation level definitions, Proceedings of the 16th IEEE International Conference on Data Engineering (ICDE), 2000, the conference version of the definitions of the DSG, G0, G1a, G1b, G1c, G2-item and G2, and of the portable levels, chapter level only
  3. Hal Berenson, Phil Bernstein, Jim Gray, Jim Melton, Elizabeth O'Neil and Patrick O'Neil, A critique of ANSI SQL isolation levels, Proceedings of ACM SIGMOD 1995, the phenomena P0 to P3 in their broad form, which the generalized definitions replace
  4. Natacha Crooks, Youer Pu, Lorenzo Alvisi and Allen Clement, Seeing is believing, a client-centric specification of database isolation, arXiv 1609.06670, the restatement of Adya's definitions, used to compare them with state-based definitions, chapter level only

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/C7AQN1/text.yaml