in Databases
298 views
0 votes
0 votes

With reference to the GATE IT 2007 | Question : 66

In the following article from GeeksForGeeks : Lock Compatibility Diagram

It can be clearly seen that if a transaction Ti owns a Shared lock on A, then a transaction Tj cannot take an Exclusive lock on A.

But in the question from 2007, we can see in the correct marked option (c), that transaction T1 takes a Lock_S(A) and then without waiting for it to be unlocked, Lock_X(A) is taken by T2, and so is the case for B, but here T2 first takes Shared lock on B and then T1 takes exclusive lock on B.

Iā€™m confused as to what is being implied here ? Does it mean that Lock_X(A) call in T2 will wait for T1, and T1 will wait for Lock_X(B) from T2, so hence a deadlock ?

in Databases
298 views

1 Answer

1 vote
1 vote
Best answer
If you read question care fully then the operations given are for transaction and no mention of order is given. That is maybe the operations may interleave or maybe the could execute in serial order. T1 takes shared lock and T2 takes exclusive lock, but when? In what order? Who takes lock first? Or maybe t2 executes after t1 finishes i.e. these are occuring serially.

To clear the confusion you must understand that individual actions of transactions are given and not the schedule meaning we can't pinpoint if some operation of T1 occurs before that of t2, we can pinpoint only the order in the same transaction i.e. inside t2 lock is acquired first before writing. And released after commit. Also all options except c violate some rule of strict 2pl.

In a tranction writes without taking exclusive lock. In option d exclusive lock is released before commit which is not allowed, in option b exclusive lock is taken for read operation which isn't invalid in itself but it must be released after commit. Only c follows all rules of strict 2pl.

Also strict 2pl doesn't care about deadlock. Let it happen if it happens.
selected by

Related questions