|
hi, have three transactions: tran1 (sessionid = 59): tran2 (sessionid = 57): tran3 (sessionid = 55): I use below statements to find out the lock informations: and my instance on a virtual pc only one cpu. my questions is: why the wait status of tran2 is still 'WAIT'(it is blocked by tran1), but the tran3 is blocked by tran2?
(comments are locked)
|
|
The simple answer is because blocks are chained. At first, a transaction will look to see if there is an existing blocking chain waiting for the resources it needs. If there is, it get's added to the tail of the blocking chain. If not, then it checks to see if it can acquire all locks it needs. If it can't it starts a new blocking chain. That's a huge over-simplification, but it gives you the general idea. So...
Again - hugely over-simplified, but gives you an idea. +1 Thanks for making it sound simpler than I was!
Apr 13 '11 at 03:44 AM
Kev Riley ♦♦
Thanks for your reply. Is it also can say that is for avoid the "Lock Starvation"?
Apr 13 '11 at 04:51 PM
Grant Wu
(comments are locked)
|
|
From MSDN/BOL
So because tran2 has not been granted any resources yet, it is WAITing whereas tran3 has some resources so is BLOCKED Kev, Thank you for your answer! Sorry, i made a mistake, my means is that: in this case, the tran1 is hold this table(with IX lock), tran2 is blocked by tran1 and tran2 is waiting for a sch-m lock. tran2 have not been granted this table. I think tran3 should be done(insert operation) when this table only be locked by IX lock.
Apr 13 '11 at 01:10 AM
Grant Wu
Do you mean why isn't the IX from tran3 compatible with the IX from tran1? A Sch-M lock is not compatible with IX, so tran2 is waiting - this puts a wait resource on the object. tran3 only wants another IX, but but is blocked by the wait already existing on the object. Don't get too mixed up with locks and blocks, locks are a cause of blocking, but not all blocking is caused by locks
Apr 13 '11 at 01:56 AM
Kev Riley ♦♦
(comments are locked)
|

