retagged by
2,562 views
5 votes
5 votes
$T1:w(A);w(B);R(C);C;$

$T2:w(B);R(B);C$

The number schedule of $T1$ and $T2$ are recoverable ________.
retagged by

3 Answers

Best answer
2 votes
2 votes

Recoverable schedules = (Dirty Read Possible and Recoverable ) + ( Dirty Read Doesn't Possible )

Dirty Read Possible and recoverable are :- 7

  T1 T2
1    
2 W(A)  
3    
4 W(B)  
5    
6    
7   R(B)
8    
9 C  
10   C

If W2(B) is at 1 ===> R1(C) should be at 5 or 8 ====> 2 possibilities

If W2(B) is at 3 ===> R1(C) should be at 5 or 8 ====> 2 possibilities

If W2(B) is at 5 ===> R1(C) should be at 6 or 8 ====> 2 possibilities

If W2(B) is at 6 ===> R1(C) should be at 5  ====> 1 possibility only ( R1(C) be at 8 is overlapped with W2(B) is at 5 and R1(C) be at or 8 )

Dirty Read Doesn't Possible means

(i) R2(B) should before W1(B)

  T1 T2
1    
2    
3    
4 W(A)  
5    
6    
7    
8 W(B)  
9    
10    
11    
12 R(C)  
13    
14    
15 C  

16

   
17    

If W2(B) is at 1 and R2(B) is at 2 ===> C should be at 3 or 5 or 9 or 13 or 16 ====> 5 possibilities

If W2(B) is at 1 and R2(B) is at 5 ===> C should be at 6 or 9 or 13 or 16 ====> 4 possibilities

If W2(B) is at 5 and R2(B) is at 6 ===> C should be at 7 or 9 or 13 or 16 ====> 4 possibilities

 ( after commenting  Deepakk Poonia (Dee) )

(ii) Even R2(B) is coming after Commit operation of T1 is also lead to NO DIRTY READ

Therefore R2(B) and Commit operation of T2 should at 16 ==> W2(B) may come at 1 or 3 or 5 or 9 or 13

====> 5 possibilities

( after commenting   Prateek Raghuvanshi )

(iii) Even W2(B) is coming between W1(B) and R2(B)  is also lead to NO DIRTY READ

therefore, if W2(B) and R2(B) at 9 and 10 ===> C should be at  11 or 13 or 16 ====> 3 possibilities

if W2(B) and R2(B) at 9 and 13 ===> C should be at  14 or 16 ====>  1 possibility (  c at 16 is overlapping )

Total possibilities of recoverable schedule = 7+18+3+1=29

edited by
5 votes
5 votes

Answer is 29. We can use the Complementary method i.e.

Number of Recoverable Schedules = All Schedules - Number of Irrecoverable Schedules

All Schedules :  $\binom{7}{4}$ = $35$

Irrecoverable Schedules :  

A Recoverable schedule is one where, for each pair of Transaction Ti and Tj such that Tj reads data item previously written by Ti the commit operation of Ti appears before the commit operation Tj . Otherwise, Schedule is Irrecoverable.

Here, To make the Schedule Irrecoverable, We just have to to do Two Things :

1. $R_2(B) \,\,after\,\,W_1(B)$  But $W_2(B)$ Not in Between them.

2. $C_1$ at the end

Let's do these things and get the answer. 

T1 T2
   
$W_1(A)$  
   
$W_1(B)$  
   
  $R_2(B)$
   
  $C_2$
$C_1$  

In the Above table, The Order will not change if we want to make Irrecoverable Schedule.(In Between things may come but the  Order of the items shown in the table will be same as in the Table)

Now, We can have Different Cases :

Case (1) : When $W_2(B)$ is at the Top i.e. At first. Then $R_1(C)$ has $3$ places to be. So, $3$ Irrecoverable Schedule

Case(2) : When $W_2(B)$ is After $W_1(A)$ then Again, $R_1(C)$ has $3$ places to be. So, $3$ Irrecoverable Schedule.

So, We have $6$ Possible Irrecoverable Schedules. 

Hence, Recoverable Schedules = 35 - 6 = $29$


The definition of recoverable schedule is as follows: A schedule $S$ is recoverable if no transaction $T$ in $S$ commits until all transactions $T'$ that have written some item $X$ that $T$ reads have committed.

When Do we say that Trans $T$ reads from $T' :$

A transaction $T$ reads from transaction $T'$ in a schedule $S$ if some item $X$ is first written by $T'$ and later read by $T$. In addition, $T'$ should not have been aborted before $T$ reads item $X$, and there should be no transactions that write $X$ after $T'$ writes it and before $T$ reads it (unless those transactions, if any, have aborted before $T$ reads $X$).

 

In Simple Words, $T$ reads from $T2$ if the schedule contains a subsequence $w2(x)...r(x),$ where $w2$ is the first write on $x$ going backwards from $r(x).$

Credit : @PrateekRaghuvanshi

edited by
2 votes
2 votes
T1          T2
W1(A)
W1(B)
R1(C)
C1
            W2(B)
            R2(B)
            C2;

 

Total Schedules possible=$\binom{7}{3}=35$

Since T1 does not read any value that is written by T2, the only way I can make non-recoverable schedules if by Making T1 write B, T2 read B(And T2's write of B occurs before Write(B) of T1) and T2 commits before T1.

Number of Non-Recoverable Schedule:

    W1(B)            R2(B)      C2         C1

Now We have only 1 place left for W1(A) and that is before W1(B)

W1(A)        W1(B)              R2(B)        C2     C1

Now W2(B) must appear before W1(B) -2 choices

And R1(C) must appear after W1(B) and before C1->3 choices

Total non-recoverable schedules this way=2*3=6.

Recoverable Schedules=Total Schedules-Non Recoverable=35-6=29

Similar Question : https://gateoverflow.in/31867/how-many-recoverable-schedules-are-possible-from-t1-and-t2

Related questions

1 votes
1 votes
2 answers
1
0 votes
0 votes
0 answers
2
amitarp818 asked Dec 5, 2023
217 views
0 votes
0 votes
0 answers
3
amitarp818 asked Dec 5, 2023
176 views
0 votes
0 votes
1 answer
4