Theoremadvanced
NP-completeness of view serializability
Also called Papadimitriou view serializability theorem.
Testing whether a schedule is view serializable is NP-complete, unlike conflict serializability, which a cycle test decides.
Deciding whether a schedule is view serializable is NP-complete. Papadimitriou proved this in 1979, by showing that view serializability is the same as the acyclicity of a polygraph, a graph with some arcs fixed and some arcs given as choices, and that polygraph acyclicity is NP-complete. The contrast with the serializability theorem is the reason why real schedulers aim at conflict serializability: one cycle test decides it, while for view serializability no polynomial test is known, and none exists unless P = NP.
Statement
A schedule in which all transactions commit is view serializable if some serial schedule of the same transactions is view equivalent to it: every read reads from the same write (or from the initial state in both), and every item has the same final write.
Theorem (Papadimitriou 1979). The problem VSR, which asks for a schedule whether it is view serializable, is NP-complete. It stays NP-complete for schedules without aborts in which every item is accessed at most four times.
Papadimitriou worked in his own model of transactions and proved the hardness through polygraphs and satisfiability. The proof below follows the same plan, polygraph acyclicity in the middle, but it is a self-contained version in the read-write action model of the schedule page, with its own gadgets.
In plain words
When a write is blind, that is, when the writing transaction never read the item, the order of that write against other writes can be hidden by a later write. A serial order must still put each writer either before or after each reader that reads from someone else, but which side is free. With many such free choices, a schedule can encode a puzzle in which each choice is a bit, and the puzzle is satisfiable exactly when some serial order exists. The proof builds such a puzzle from a 3-SAT formula.
Proof
Membership in NP. A certificate is a serial order of the transactions. For the serial schedule , compute for each read the last earlier write of the same item, and for each item its last write. Do the same for , with occurrences of actions as identifiers. This takes time polynomial in the length of , and is view equivalent to exactly when the two results agree.
The ordering problem. An instance of ORD is a finite set of nodes and a set of triples of distinct nodes. A solution is a linear order of such that for every triple
that is, comes before and is not between them. An arc is a constraint alone. This is the polygraph acyclicity problem in the form of linear orders: each triple is a fixed arc and a choice between the arcs and .
Step 1: from ORD to VSR. Given an instance with nodes , take transactions and one more transaction . For each triple use a fresh item and append the actions
for each arc use a fresh item and append , and end with the commits . Each transaction consists of its actions in the order of the schedule .
Claim. is view serializable if and only if the instance has a solution.
Proof. Look at the item of a triple. In , the read reads from , and the final write of is . In a serial schedule , the writers of are , and , and the read of sees the last of them that comes before . So agrees with on exactly when is the last of the three writers, and is the last writer before . The second condition means , because comes after , and that is not between and . The first condition then only adds . For the item of an arc, the same argument gives . If is view equivalent to , its order on is therefore a solution. If is a solution, the serial schedule in the order followed by meets all these conditions, item by item.
Step 2: from 3-SAT to ORD. Let be a 3-SAT formula with variables and clauses , each with three literals. Say that a node has range if the instance holds the arcs and .
The spine. A chain of arcs fixes the order of these nodes:
The clause cells are, for in turn, the nodes and then for . Call everything before the first cell the left zone and everything after the last cell the right zone. In what follows, is fixed and we drop it from the names.
Variable gadget. For each variable , a node with range and the triple . In a solution, lies between and or between and . Read the first case as false and the second as true.
Clause gadget. For each clause, a node with range and the triples and . In a solution, lies in one of the three gaps : it is after and before , and it can be neither between and nor between and .
Literal gadget. For the literal of cell , on the variable , four nodes:
- with range and with range ;
- with range , with range , and the arc ;
- the triples , and ;
- if , the triples and ; if , the triples and .
The instance has nodes and constraints, and it is built in polynomial time.
Lemma (a false literal closes its gap). In a solution, if the literal of cell is false under the assignment read from the variable gadgets, then is not in the gap .
Proof. Take with false, so . The node is before , so it is not after , and the triple forces : is in the left zone. Then , so the triple forces . The node is after , so it is not before , and its triple forces : is in the right zone. Then , so the triple forces . Now and , and the triple says that is not between and , so is not in . For with true, , and the triples and again push before into the left zone and after into the right zone. The rest is the same.
Soundness. Let the instance have a solution. Read the assignment from the variable gadgets. For each clause, lies in some gap , so by the lemma the literal of cell is true. So is satisfied.
Completeness. Let an assignment satisfy . Keep the spine order and place the other nodes as follows.
- Put right after if is false, and right after if is true.
- In a cell whose literal is false, put right after BEGIN, right before END, right after and right after .
- In a cell whose literal is true, use the order .
- For each clause, choose a cell with a true literal and put right after , before .
All arcs hold. The variable triples hold by the placement of . The clause triples hold because is in a gap. The triple holds with in a true cell and with in a false cell; the triple holds with in a true cell and with in a false cell. The triple holds in the cell because , and in every other cell of the clause because there and lie between and , while lies outside that interval. For the literal triples: in a false cell, is before all of , and , and is after all of them. In a true cell with , is in the right zone, so and . In a true cell with , is in the left zone, so and . So every constraint holds.
Conclusion. Steps 1 and 2 give a polynomial-time reduction from 3-SAT to VSR. In the schedule of Step 1, every item has at most four actions and no transaction aborts. With membership in NP, VSR is NP-complete.
Consequences
- Schedulers use conflict serializability. It is a subclass of VSR that the serializability theorem decides with one cycle test, and that is closed under prefixes. View serializability is neither easy to test nor closed under prefixes, so an online scheduler could not use it even with unlimited time per step.
- Exact view tests are exponential in the worst case. A test can try all serial orders, or search over the choices of the polygraph. Both are fine for a handful of transactions and hopeless in general.
- Rules that exploit blind writes are local. The Thomas write rule accepts some schedules that are view serializable but not conflict serializable. It does so by a fixed rule on timestamps, not by solving the hard problem.
- The same method gives other hardness results. Polygraph acyclicity is the core of several later proofs, for example for multiversion serializability, where the version function adds more freedom of the same kind.
Tightness
- Blind writes are needed. If every transaction reads each item before it writes it, view serializability coincides with conflict serializability, and the test is polynomial. The hard instances above rely on writes such as that no read precedes.
- A fixed number of transactions is easy. For transactions the brute force test takes time on a schedule of actions, which is polynomial for each fixed . The hardness needs a growing number of transactions.
- NP-hardness, not more. The problem is in NP, so it is not PSPACE-hard unless NP = PSPACE.
- The model matters. The statement is about the read-write action model with view equivalence. Papadimitriou proved his result in a model of his own, and a change of model, for example a different notion of equivalence, needs its own proof.
History
Papadimitriou (1979) studied the serializability of schedules of read and write steps, introduced the polygraph of a schedule, and proved that testing serializability is NP-complete, by a reduction from satisfiability through polygraph acyclicity. The same paper compared this class with the class that the precedence graph decides, which is a polynomial subclass. Garey and Johnson (1979) included serializability of database histories in their list of NP-complete problems. Later textbooks, such as Weikum and Vossen (2001), separate final-state, view and conflict serializability and present the hardness of the view test as the reason for the practical focus on conflict serializability.
References
- Christos H. Papadimitriou, The serializability of concurrent database updates, Journal of the ACM 26(4), 1979, pages 631 to 653, the polygraph of a schedule, the NP-completeness of polygraph acyclicity, and the NP-completeness of testing serializability
- Gerhard Weikum and Gottfried Vossen, Transactional Information Systems, Morgan Kaufmann, 2001, Chapter 3 (view serializability, the polygraph characterization and the complexity of the test)
- Michael R. Garey and David S. Johnson, Computers and Intractability, W. H. Freeman, 1979, the appendix list of NP-complete problems, the entry on serializability of database histories
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag RBVB1W Edit this page History Report an error Markdown