2,796 views
1 votes
1 votes
 

I have been reading about the tree protocol as an approach in locking management in databases. I read that it is deadlock free but I am not sure how it works.
Example:
enter image description here

Assume that T1 has locked B, D, E in exclusive mode.
According to the rules:
enter image description here

T2 can lock H (allowed by rule 2).
Now if T1 wants to lock H it can not despite the fact that it has locked the parent D since T2 has the lock so it waits.
If T2 now wants to lock G it has to lock D but D is locked by T1 so it has to wait. Hence deadlock.
What am I misunderstanding in the algorithm?

2 Answers

0 votes
0 votes
As far as i have understood, Tree has a direction from top to bottom, and if T2 wants to lock both G and H then it has to lock the common parent of both first, Here T2 is not allowed to request a lock on G, because it can't climb upwards. Now T2 can request lock on J only and not on any other nodes.
"The first lock by Ti can be on any data item", that time itself T2 should have taken care before it locked H if it needed G and H both.
edited
0 votes
0 votes
t2 can lock h if it's parent is locked suppose h is currently locked that means first d was locked and still d is locked now d is unlocking by t1 and now d unlocked now t1 comes and it can lock d and  becoz parent is locked so t1 can lock g it is happening locking and unlocking can be happen in any way and becoz of t1 ,t2 ,.....tn will never request to lock d again so deadlock not possible here.

Related questions

0 votes
0 votes
0 answers
1
indrajeet asked Jun 16, 2016
588 views
In Graph based Protocol :-Why acquireing second lock on a data item needs to lock their parent data in tree .please explain
1 votes
1 votes
1 answer
2
Heena Jain asked Aug 5, 2017
684 views
Is there a chance for Deadlock in Graph based protocol?