Sql-server – have RID locks if I have a clustered index

blockinglockingsql servert-sql

I have configured extended_events to capture blocks on my database. Now I can see that I had blocks on one table that have been causing blocks problem. I can see that one UPDATE query can not go through and the detail says:

waitresource="RID: 9:1:6162688:0" 

I understand why the UPDATE can not go through, it is because the query has to read the whole table and it blocks when it tries to read the RID. I am guessing that RID has a X lock.

My questions are:

  1. How can I know which query is locking the RID ?
  2. Why do I have locks at the RID level if I have a clustered index?

Best Answer

Use sp_WhoIsActive, a totally free script from MVP Adam Machanic:

sp_WhoIsActive @get_locks = 1

That adds an XML column of lock data for each running query. You can see which indexes, objects, databases, etc are locked, what kind of locks are held, and how many of them are held.