3.7k views

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 | 3.7k views
+2

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.

0
one simple doubt here T2 is reading the data A which is written by the transaction T1 but here in T2 the data A has been rad only nowhere it is used so why we are concerning about irrecoverable ...option D is also i think write.

but their is another data C and B which is written by T2 ...is this is the reason why it becomes irrecoverable ?

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.

by Active (2.3k points)
selected
0
0

What you told is correct. But that argument is not enough to say A is false. Because A option is saying without restarting both T1 and T2, atomicity cannot be ensured. It is not saying restarting both ensures atomicity.

If you ask me the answer for this I'll say A now, but I haven't seen Transactions for a long time so probably it is wrong. Lets wait till keys are out.

http://www.ict.griffith.edu.au/~rwt/uoe/1.1.ccc.html

0
@Arjun Sir how are u discarding the option B i don't think it can be discarded.

0
My point for B not being correct is its second part. The given schedule is unrecoverable- so first part is correct. But atomicity can be ensured.
+1
i don't know if i am interpreting it the wrong way but i think what it means to say is that in the current situation (that is T1 failing) it cannot ensure transaction atomicity and the schedule being irrecoverable has a part to play in it.
+1
In the current situation we abort transactions 1 and 2 and restart them. This violates the durability property of transactions but can ensure atomicity. If a similar situation comes again we repeat the same. This may even go to an infinite loop. But we are not violating any conditions for ATOMICITY here.
+1
in option A it says abort T2 but when ??

it can only be aborted after operation 9 but can we abort a commited transaction ??
+1
We cannot as it violates Durability property. But if we sacrifice durability we can abort.
+5
Official key is B, so your answer is the best for GATE :)
+2

Atomicity is a property of a transaction, right ? How is atomicity related to a schedule ? First part of the option B seems correct, but the part 'cannot ensure atomicity' how can this be correct ? All the steps in T2 were successfully commited and all the steps in T1 are aborted, so in my opinion, Consistency is the property that is violated, since no transaction has executed partially atomicity is NOT violated ...

0
how can we abort a committed transaction?
–1

@Arjun sir A and B both are correct according to me..

0
Will see later, transactions I have to see.
0
ok sir ..
0
@Anirudh  A is only correct if they given additionally  T1 must commit before T2 then A will be fine otherwise we do 1000 times abort T2 and restart T1, T2 we can't gives surity whather they will succed
+6
@Anirudh : How can you abort a transaction if it's already committed? And since we can't abort T2 we can't ensure atomicity as it will have the side effects of T1. Option B is the only correct answer here.
+9
When transaction is abort (fail) after line 9 then T1 will rollback but T2 will committed show it will never roll back this the violation of atomicity property.
+2
By the word abort,does it mean rollback or to kill the transaction without rollback?
+2

ABORT rolls back the current transaction and causes all the updates made by the transaction to be discarded. This command is identical in behavior to the standard SQL command ROLLBACK, and is present only for historical reasons

https://stackoverflow.com/questions/11859292/difference-between-abort-and-rollback

+3

Arjun can we say becoz of dirty read this shedule is non recoverable ?

0
The reasoning of making A false is not convincing in the answer.Althugh b is the strongest answer available.A is saying that option A is must if we need atomicity. It is necessary step,regardless of it successes next time or not.But since we cannot do this as it is irrecoverable schedule so B is correct
0
Option A is false because it does not mention about the undo operation that has to be performed on transaction-1,rather it simply says that restart transaction-1.
0

Sorry, either I didn't get you completely or you have not explained clearly.  This is what I've understood.  Please point out mistakes in my explanation if there is any (otherwise would eternally be into oblivion.)-

A - It's wrong because redoing $T1$ won't help, undoing $T1$ will... If the option were "$T2$ must be aborted (although not mandatory)  and then $T1$ should be undone and $T2$ should be redone. Then it would be correct.

C - Incorrect because nothing being told what do to with $T1$ (it should be undone)

0
What i read in class is "If a transaction Ti reads the data item written by transaction Tj then the commit operation of Tj must appear before the commit operation of Ti. Then we can say S is Recoverable Schedule." Is this correct ?

and "If transaction fails before first commit everything is recoverable, problem is after first commit."
0
Yes , if T2 reads something which is written by  T1 then T2 should commit after T1.i.e. there should not be dirty read for a schedule for it to be recoverable.

"If transaction fails before first commit everything is recoverable, problem is after first commit."

This is also correct because we will undo all the operations in log file and will start doing everything from scratch if crash happens before first commit.$\implies$ recoverable schedule.

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.

by Loyal (5.2k points)
+1 vote

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

by Active (5k points)
edited
+1
In transaction T2,  after reading A  no write action is performed.

Hence we are sure that incorrect A value is read but not used anywhere (and it does not effect B and C's value).

Therefore rolling back of T2 may not be required.

But i agree that spurious read has occured in T2.

Please explain how option D is eliminated
+2
option D is eliminated because its clearly saying schedule s is recoverable which is irrecoverable because t2 read the data item 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 committed t2 cant change that read value of A which taken from t1.
0
what exactly is the answer to this question then ?? A or B. since both cannot be correct ??

and also does aborting involve undoing the operations and redoing them since by the time stamp 9 the transaction T2 has already commited .
0
In option A...When to abort T2?

In option B...How to define atomicity??

According to me Ans is D

Because T2 is committed that means it's history is recorded in transaction log file to maintain ACID rules.

which also included "which value of A which was read by T2" and That value was written by T1.

As we know the read(A) of T1 [Initial value] and Write(A) of T1 extracted from T2 log file ,

therefore we can recover the S

by (407 points)
+2
simply dirty read so nonrecoverable sooption b is appropiate