Algorithm Search⌘K

Definitioncore

One-copy serializability

Also called 1SR.

An execution on replicated data is one-copy serializable when it is equivalent to a serial execution on a single copy of each item.

One-copy serializability (1SR) is the standard correctness criterion for transactions on replicated data. The database keeps several copies of each item, at different sites, and the system turns each read and write of an item into reads and writes of copies. An execution is one-copy serializable if the users cannot tell it apart from a serial execution of the same transactions on a database with one copy of each item: each transaction reads the same values, and the database ends in the same state. Ordinary serializability of the copy-level execution is not enough. An execution can be conflict serializable as a history over copies and still give results that no one-copy execution gives.

Definition

The definition is that of Bernstein, Hadzilacos and Goodman (1987), Section 8.3. Let T0,T1,…,TnT_0, T_1, \dots, T_n be transactions over items x,y,…x, y, \dots, where T0T_0 writes the initial value of every copy. Each item xx has copies xA,xB,…x_A, x_B, \dots at sites A,B,…A, B, \dots.

Replicated data history. A translation maps each read ri[x]r_i[x] to a read ri[xA]r_i[x_A] of one copy, and each write wi[x]w_i[x] to writes wi[xA1],…,wi[xAm]w_i[x_{A_1}], \dots, w_i[x_{A_m}] of one or more copies. A replicated data (RD) history is a partial order of the translated operations, plus commits and aborts, such that:

  1. it keeps the order of the operations inside each transaction;
  2. every copy that is read was written before, at least by T0T_0;
  3. any two operations on the same copy, at least one of them a write, are ordered;
  4. if TiT_i writes xx and then reads xx, it reads a copy that it wrote.

A one-copy (1C) history is an ordinary history over the items, as if each item had one copy. As in the book, take every history to be the committed projection of itself.

Reads-from on items. TjT_j reads xx from TiT_i in an RD history HH if, for some copy xAx_A, wi[xA]<rj[xA]w_i[x_A] < r_j[x_A] and no other write of xAx_A comes between them. A transaction reads each item at most once and reads one copy, so this relation is a function. In a 1C history, reads-from is the usual relation on items.

Final writes. wi[xA]w_i[x_A] is a final write for the copy xAx_A in HH if every other write of xAx_A comes before it. In a 1C history, the final write for xx is the last write of xx.

Equivalence. An RD history HH is equivalent to a 1C history H1CH_{1C} over the same transactions if

  1. TjT_j reads xx from TiT_i in HH if and only if TjT_j reads xx from TiT_i in H1CH_{1C}, and
  2. for each final write wi[x]w_i[x] in H1CH_{1C}, wi[xA]w_i[x_A] is a final write in HH for some copy xAx_A of xx.

One-copy serializability. HH is one-copy serializable if it is equivalent to a serial 1C history.

This is view equivalence between a history over copies and a history over items. Conflict equivalence cannot be used, because the two histories have different operations: two writes of xx conflict in H1CH_{1C}, but their translations may touch different copies. The second condition asks only that the last write of each item reach some copy. It does not ask the copies to be equal at the end.

A sufficient test. Let SG(H)\mathrm{SG}(H) be the serialization graph of HH over copies, with an edge Ti→TjT_i \to T_j for each pair of conflicting operations on one copy with TiT_i's operation first. A replicated data serialization graph (RDSG) is SG(H)\mathrm{SG}(H) with edges added so that (a) any two transactions that write xx are connected by a path, in one direction or the other, and (b) if TjT_j reads xx from TiT_i, TkT_k writes xx, k≠i,jk \neq i, j, and there is a path from TiT_i to TkT_k, then there is a path from TjT_j to TkT_k. Theorem 8.4 of the book states: if HH has an acyclic RDSG, then HH is 1SR, and a topological order of the graph is an equivalent serial order. Most correctness proofs of replica control protocols use this theorem or Theorem 8.3, which states that the same reads-from relation as a serial 1C history in an order consistent with SG(H)\mathrm{SG}(H) is enough.

Examples and non-examples

Each claim below was checked by a brute-force search over all serial orders, with the helper of the read-one write-all page. T0T_0 is implicit.

Read one, write all. H=w1[xA] w1[xB] c1 r2[xB] c2H = w_1[x_A]\, w_1[x_B]\, c_1\, r_2[x_B]\, c_2. T2T_2 reads xx from T1T_1, so the equivalent serial 1C history is T1 T2T_1\, T_2. Write-all with strict two-phase locking gives histories of this kind.

A serial history over copies that is not 1SR. This is history H1H_1 of Section 8.1 of the book, in which T1T_1 wrote only one copy of xx:

H1=r1[yC] w1[xA] c1 r2[xB] w2[yC] c2.H_1 = r_1[y_C]\, w_1[x_A]\, c_1\, r_2[x_B]\, w_2[y_C]\, c_2.

T2T_2 reads xBx_B from T0T_0, an old copy. In a serial 1C history in the order T1 T2T_1\, T_2, T2T_2 would read xx from T1T_1. In the order T2 T1T_2\, T_1, T1T_1 would read yy from T2T_2. Neither holds, so H1H_1 is not 1SR, although it is serial as a history over copies.

A conflict serializable history over copies that is not 1SR. This is history H4H_4 of Section 8.4. T1=r1[x] w1[y]T_1 = r_1[x]\, w_1[y] and T2=r2[y] w2[x]T_2 = r_2[y]\, w_2[x], with copies xA,xB,yC,yDx_A, x_B, y_C, y_D:

H4=r1[xA] r2[yD] xA fails yD fails w1[yC] w2[xB] c1 c2.H_4 = r_1[x_A]\, r_2[y_D]\, x_A \text{ fails}\, y_D \text{ fails}\, w_1[y_C]\, w_2[x_B]\, c_1\, c_2.

No two operations touch the same copy, so the copy-level serialization graph has no edges between T1T_1 and T2T_2. But each transaction reads an item that the other one writes, and neither reads the other's value, so no serial 1C history fits. Two-phase locking on copies cannot prevent this, because the logical conflicts never become conflicts on copies. The available copies algorithm adds checks at commit for this reason.

Copies that differ at the end. H=w1[xA] w1[xB] c1 w2[xA] c2H = w_1[x_A]\, w_1[x_B]\, c_1\, w_2[x_A]\, c_2. At the end xAx_A holds the value of T2T_2 and xBx_B holds the value of T1T_1. The history is 1SR, and in two ways: in the order T1 T2T_1\, T_2 the final write of T2T_2 is the final write of xAx_A, and in the order T2 T1T_2\, T_1 the final write of T1T_1 is the final write of xBx_B. The criterion speaks about what transactions read, so a stale copy is harmless as long as no one reads it.

A stale read that 1SR allows. H=w1[xA] c1 r2[xB] c2H = w_1[x_A]\, c_1\, r_2[x_B]\, c_2, where T2T_2 starts after T1T_1 commits. T2T_2 reads the initial value from xBx_B. The history is 1SR in the order T2 T1T_2\, T_1: the definition has no notion of real time. A client that sees T1T_1 commit and then starts T2T_2 can still see the old value. Strong one-copy serializability, also called strict serializability, adds the rule that the serial order must respect the real-time order of transactions that do not overlap.

One copy per item. If every item has exactly one copy, an RD history is an ordinary history, and the definition becomes view serializability. So deciding whether a history is 1SR is NP-complete in general, by the NP-completeness of view serializability. Protocols therefore aim at sufficient conditions, such as an acyclic RDSG, that they can enforce one step at a time.

  • Serializability and view serializability. 1SR is view serializability where the history on the left is over copies and the serial history on the right is over items.
  • Multiversion serializability. Multiversion histories use the same idea: a history over versions is correct if it is equivalent to a serial history over items with one version each. Bernstein, Hadzilacos and Goodman point out that the two theories are very similar.
  • Strong one-copy serializability. 1SR plus the real-time order of non-overlapping transactions. It is the transactional form of linearizability, which is defined for single operations on single objects.
  • Weaker criteria. Many replicated systems give less than 1SR: snapshot isolation on replicas, the consistency models of replicated stores, and the highly available transactions of Bailis et al., which can run without coordination when the network is partitioned. In the asynchronous model with partitions that can last forever, no system can give 1SR and stay available at the same time.
  • Protocols. Read-one write-all and its available copies form, primary copy locking and quorum replication with two-phase locking are the classic protocols that give 1SR.

References

  1. Philip A. Bernstein, Vassos Hadzilacos and Nathan Goodman, Concurrency Control and Recovery in Database Systems, Addison-Wesley, 1987, Chapter 8, Replicated Data: the write-all-available example (Section 8.1), RD histories, 1C histories and the definition of 1SR with Lemma 8.2 and Theorem 8.3 (Section 8.3), and the replicated data serialization graph with Theorem 8.4 (Section 8.4)
  2. Philip A. Bernstein and Nathan Goodman, An algorithm for concurrency control and recovery in replicated distributed databases, ACM Transactions on Database Systems 9(4), 1984, pages 596 to 615, one-copy serializability as the correctness criterion for replicated data, and its use to prove the available copies algorithm correct

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/CXP807/text.yaml