Consider the following two transactions : T1 and T2.
Which of the following schemes, using shared and exclusive locks, satisfy the requirements for strict two phase locking for the above transactions?
Strict 2 PL ensures conflict serializable serial schedule based on Lock Point but above mentioned scheduled not conflict serializable. And 2 PL says other transaction can not R/W uncommitted values but it is happening here.
So how is this 2 P L ?
ping @Krish__, @rahul sharma 5, @Red_devil, @Shivam Chauhan, @Tuhin Dutta, @Anu007, @Ashwin Kulkarni @reena_kandari and @srestha ji.
The above question just asks if the modified transactions can lead to a strict 2PL schedule. The schedule itself hasn't been given and we can only check if:
1. Exclusive locks should be released after the commit for each transaction.
2. No Locking of the same data item done after the first Unlock and vice versa.
3. The transactions have proper shrinking and growing phase.
@akku_126 Yes, It will be in Strict 2PL if there are no X_LOCKS() provided it follows 2PL since condition for a schedule being Strict 2PL is on X_Locks().
Answer is (C).
Many of you would point a DEADLOCK and I won't deny But see Question just asks for requirement to follow Strict 2PL. Requirement are
In 2Pl deadlock may occur BUT it may be that it doesn't occur at all.
Consider that in option (C) if both execute in serial order without concurrency. Then that is perfectly valid and YES it follows Strict 2PL.
"No locking can be done after the first unlock and vice versa" .
This is the basic requirement of 2PL.
2 Phase Locking requires locking and unlocking in two phases:
For Strict 2PL, All X_LOCKS() are held till commit in addition to to locks being 2PL.
A) is eliminated because write (B) is done in S1 without acquiring Exclusive lock on B.
B) is eliminated because unlock (A) should happen only after commit in a strict 2pL.
D) is also eliminated. The reason is exactly same as B)
C) is the answer.
3) Shared lock can be unlocked anytime Exclusive only after commit
4) is 2pl
2) is Wrong Exclusive cannot take other's Exclusive Lock.
1) To write X you need Exclusive Lock So WRONG
Correct If Wrong.
For option a,there is a shared lock on B, so how it can write B, therefore wrong option.
For option b, exclusive lock on A is unlocked before commit , therefore wrong option.
For option c, all is correct as exclusive lock on B is removed after commit .
For option d, exclusive lock on B is removed before commit, therfore wrong option.