write(T1, balx), read(T2, balx), write(T1, balx), commit(T2), abort(T1)
I'm revising for an exam and these are one of the questions that I've been looking over on the mock paper.
According to the Marking Scheme the answer is that the transaction is serializable. But I just don't understand how.
T1 and T2 get trapped in a cycle as T1 points to T2 and then point backs to T1 in a precedence graph, therefore not making it serializable. Is the marking wrong or am I missing something here?
If a precedence graph contains a single edge Ti → Tj, then all the instructions of Ti are executed before the first instruction of Tj is executed. If a precedence graph for schedule S contains a cycle, then S is non-serializable. If the precedence graph has no cycle, then S is known as serializable.
A schedule will view serializable if it is view equivalent to a serial schedule. If a schedule is conflict serializable, then it will be view serializable. The view serializable which does not conflict serializable contains blind writes.
Example for Conflict Serializability – Two operations are said to be conflicting if the belong to different transaction, operate on same data and at least one of them is a write operation. Constructing the precedence graph, we see there are no cycles in the graph. Therefore, the schedule is Conflict Serializable.
A schedule is called conflict serializable if it can be transformed into a serial schedule by swapping non-conflicting operations. For a schedule to be conflict serializable, there should be no cycle present in its precedence graph. Cycle between T1 and T2.
I think the key thing here is that T1 abort. If I am no mistaken until a transactions commits then it is safe to assume the disk has not been modified. Which means when T1 aborts the state of the database was the same as because this sequence of operation. And this is the T2 is viewing.
Thus, if we had
write(T1, balx), write(T1, balx), abort(T1), read(T2, balx), commit(T2)
read(T2, balx), commit(T2), write(T1, balx), write(T1, balx), abort(T1)
Then the state of the database and of the transactions T2 will be the same as the one in your example. Now if T1 had committed, you will be correct by evoking the precedence graph.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With