Thursday, May 7, 2015

SQL SERVER LOCK MONITORING

To monitor LOCK chains:

SELECT
        t1.resource_type,
        t1.resource_database_id,
        t1.resource_associated_entity_id,
        t1.request_mode,
        t1.request_session_id,
        t2.blocking_session_id
    FROM sys.dm_tran_locks as t1
    INNER JOIN sys.dm_os_waiting_tasks as t2
        ON t1.lock_owner_address = t2.resource_address;

Use the resource associated entity id from the above query and use it with below query:

  SELECT object_name(object_id), *
    FROM sys.partitions
    WHERE hobt_id='7277817043870613504'

To find the object name, use the resource associated entity id in the hobit.

What is hobit ?

Its short name for Heap or Binary tree in SQL Server.

Reference:

http://thehobt.blogspot.com/2009/02/what-heck-is-sql-server-hobt-anyway.html