Machine-translated by Google. Questions are authored in English.
Top

Discussion

Consider the database transactions T1 and T2, and data items X and Y. Which of the schedule(s) is/are conflict serializable?

Transaction T1Transaction T2
R1(X)
W1(Y)
R1(X)
W1(X)
COMMIT(T1)
W2(X)
W2(Y)
COMMIT(T2)

  • A.R1(X), W2(X), W1(Y), W2(Y), R1(X), W1(X), COMMIT(T2), COMMIT(T1)
  • B.W2(X), R1(X), W2(Y), W1(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)
  • C.R1(X), W1(Y), W2(X), W2(Y), R1(X), W1(X), COMMIT(T1), COMMIT(T2)
  • D.W2(X), R1(X), W1(Y), W2(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)

Answer: B

The conflict serializable schedule is W2(X), R1(X), W2(Y), W1(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1).

Draw the precedence graph: for each pair of conflicting operations (same item, different transactions, at least one a write), add an edge from the transaction that acts first. The schedule is conflict serializable exactly when the graph has no cycle.

  • This schedule: W2(X) before R1(X) and before W1(X), and W2(Y) before W1(Y). Every edge is T2 → T1, so it is equivalent to the serial order T2, T1.
  • R1(X), W2(X), ... , R1(X): R1(X) before W2(X) gives T1 → T2, and W2(X) before the second R1(X) gives T2 → T1: a cycle.
  • R1(X), W1(Y), W2(X), W2(Y), R1(X), ...: T1 → T2 on X and on Y, but W2(X) before the second R1(X) gives T2 → T1: a cycle.
  • W2(X), R1(X), W1(Y), W2(Y), ...: T2 → T1 on X but W1(Y) before W2(Y) gives T1 → T2: a cycle.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.