Options

SQL Monitor Causing Deadlocks

We are seeing deadlocks in our application when SQL Monitor is enabled at one of our client sites. I am waiting for client to confirm SQL Monitor version as suspect it may be an older version and this may be resolved in later version - I am hoping you can confirm this so we can ask client to upgrade safely. What we are seeing is the following:

  • Our stored procs are using #temp tables - when an application uses these it will cause Sch-M locks
  • RedGate SQL Monitor query is using NOLOCK option - this causes Sch-S locks which results in blocks

SELECT TOP 10
tb.name AS [temp_table_name],
stt.row_count AS [row_count],
stt.used_page_count * 8 AS [used_pages],
stt.reserved_page_count * 8 AS [reserved_pages]
FROM
tempdb.sys.partitions prt WITH (NOLOCK)
INNER JOIN
tempdb.sys.dm_db_partition_stats stt WITH (NOLOCK)
ON prt.partition_id = stt.partition_id AND prt.partition_number = stt.partition_number
INNER JOIN
tempdb.sys.tables tb WITH (NOLOCK)
ON stt.object_id = tb.object_id
ORDER BY
stt.reserved_page_count


Combination of Sch-S and Sch-M locks causes deadlocks. Why does SQL Monitor need to use NOLOCK on the system tables? And is this changed/fixed in latest version?

thanks 
Tagged:

Answers

Sign In or Register to comment.