edited by
14,233 views
62 votes
62 votes

Consider the partial Schedule $S$ involving two transactions $T1$ and $T2$. Only the $\textit{read}$ and the $\textit{write}$ operations have been shown. The $\textit{read}$ operation on data item $P$ is denoted by $\textit{read(P)}$ and $\textit{write}$ operation on data item $P$ is denoted by $\textit{write(P)}$.
$$\overset{\large{\text{Schedule S}}}{\begin{array}{c|ll}
\textbf{Time Instance}&    \rlap{\text{Transaction ID}}\\&\textbf{T1}&  \textbf{T2} \\\hline
1&     \text{read(A)}  \\ 
2&     \text{write(A)}\\   
3&     & \text{read(C)}     \\
4&     & \text{write(C)}     \\
5&     & \text{read(B)}  \\
6&     & \text{write(B)}     \\  
7&     & \text{read(A)}     \\
8&     & \text{commit}       \\
9&     \text{read(B)} \\
\end{array}}$$

Suppose that the transaction $T1$ fails immediately after time instance 9. Which of the following statements is correct?

  1. $T2$ must be aborted and then both $T1$ and $T2$ must be re-started to ensure transaction atomicity
  2. Schedule $S$ is non-recoverable and cannot ensure transaction atomicity
  3. Only $T2$ must be aborted and then re-started to ensure transaction atomicity
  4. Schedule $S$ is recoverable and can ensure transaction atomicity and nothing else needs to be done
edited by

5 Answers

Best answer
84 votes
84 votes

The correct option is B.

Why A is not correct because it says abort transaction T2 and then redo all the operations .

But is there a guarantee that it will succeed this time ??(no maybe again T1 will fail).

Now as to why b is correct because as the other answer points out it is by definition an irrecoverable schedule now even if we start to undo the actions on by one(after t1 fails) in order to ensure transaction atomicity. Still we cannot undo a committed transaction. Hence, this schedule is unrecoverable by definition and also not atomic since it leaves the data base in an inconsistent state.

selected by
24 votes
24 votes

if transaction fails, atomicity requires effect of transaction to be undone. Durability states that once transaction commits, its change cannot be undone (without running another, compensating, transaction). 
Recoverable schedule: A schedules exactly where, for every set of transaction Ti and Tj. If Tj reads a data items previously written by Ti, then the commit operation of Ti precedes the commit operation of Tj. 
Aborting involves undoing the operations and redoing them since by the time stamp it is aborted.

Option (A): T2 must be aborted and then both T1 and T2 must be re-started to ensure transaction atomicity. It is incorrect because it says abort transaction T2 and then redo all the operations. But there is no gaurantee that it will succeed this time as again T1 may be fail.

Option(B): Schedule S is non-recoverable and cannot ensure transaction atomicity. Correct, it is by definition an irrecoverable schedule so now even if we start to undo the actions one by one(after t1 fails) in order to ensure transaction atomicity. Still we cannot undo a commited transaction. hence this schedule is irrecoverable by definition and also not atomic since it leaves the database in an inconsistent state. Simply dirty read so nonrecoverable.

Option (C): Only T2 must be aborted and then re-started to ensure transaction atomicity. It is incorrect because it says abort only transaction T2 and then redo all the T2 operations. But this is dirty read problem as it is reading the data item A which is written by T1 and T1 is not committed. Again it will be the dirty read problem. So incorrect.

Option (D): Schedule S is recoverable and can ensure transaction atomicity and nothing else needs to be done. Incorrect, it is clearly saying that schedule s is recoverable but it is irrecoverable because T2 read the data item A which is written by T1 and T1 failed and rollback, at the rollback T1 start undo all operations and modified the value of A with previous value but T2 is already committed so T2 can’t change the read value of A which was earlier taken from T1.

2 votes
2 votes

A. T2 must be aborted and then both T1 and T2 must be re-started to ensure transaction atomicity

     because according to atomicity "execute all the operations of the transaction  or none of them"

  B.Schedule S is non-recoverable and cannot ensure transaction atomicity because t1 is writing data item A which is read by t2 and t2 is committed before t1.... but here t1 fails and rollbacking of comitted transaction is not possible so its irrecoverable schedule
so option A&B is true

edited by
1 votes
1 votes

As per Korth

A recoverable schedule is one where, for each pair of transactions $T_i$ and $T_j$ such that $T_j$ reads a data item previously written by $T_i$, the commit operation of $T_i$ appears before the commit operation of $T_j$.

 

A cascadeless schedule is one where, for each pair of transactions $T_i$ and $T_j$ such that $T_j$ reads a data item previously written by $T_i$, the commit operation of $T_i$ appears before the read operation of $T_j$.
It is easy to verify that every cascadeless schedule is also recoverable.

 

We can simplify the definitions as:

A schedule is said to be recoverable if for every dirty read, the transaction who's object has been read "dirtily" commits before the transaction that performs the dirty read.

A schedule is said to be cascadeless if there's no dirty read.

 

Clearly, the schedule in the question is non-recoverable. Hence, Option B

Answer:

Related questions

51 votes
51 votes
4 answers
1