SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Data Collector being blocked by user query


Data Collector being blocked by user query

Author
Message
Leo.Miller
Leo.Miller
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10667 Visits: 1603
I've a strange situation, where the Data Collector is being blocked by a long running user query. The blocked query is:
SELECT  
@plan_handle AS plan_handle,
@statement_start_offset AS statement_start_offset,
@statement_end_offset AS statement_end_offset,
[dbid] AS database_id,
[objectid] AS object_id,
OBJECT_NAME(objectid, dbid) AS object_name,
[query_plan] AS query_plan
FROM
[sys].[dm_exec_text_query_plan](@plan_handle, @statement_start_offset, @statement_end_offset) dm

And the blocking query is a pretty ugly MERGE statement with 288 lines of conditions, tests and actions.
When I look at the blocked object I find the Data Collector is trying to get a Sch-S on a Temporary table (#TableName) in TempDB, that the MERGE command has a Sch-M lock - GRANT lock on. SPID 73 is the data Collector, SPID 120 is the user MERGE


Besides the obvious, which is to improve the code or the way things are done, is there any way to stop the Data Collecting being blocked? I would have expected the design to be such that this can't happen.

Leo
Nothing in life is ever so complex that with a little work it can't be made more complex
sgmunson
sgmunson
SSC Guru
SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)SSC Guru (79K reputation)

Group: General Forum Members
Points: 79446 Visits: 6503
Leo.Miller - Tuesday, February 13, 2018 12:09 PM
I've a strange situation, where the Data Collector is being blocked by a long running user query. The blocked query is:
SELECT  
@plan_handle AS plan_handle,
@statement_start_offset AS statement_start_offset,
@statement_end_offset AS statement_end_offset,
[dbid] AS database_id,
[objectid] AS object_id,
OBJECT_NAME(objectid, dbid) AS object_name,
[query_plan] AS query_plan
FROM
[sys].[dm_exec_text_query_plan](@plan_handle, @statement_start_offset, @statement_end_offset) dm

And the blocking query is a pretty ugly MERGE statement with 288 lines of conditions, tests and actions.
When I look at the blocked object I find the Data Collector is trying to get a Sch-S on a Temporary table (#TableName) in TempDB, that the MERGE command has a Sch-M lock - GRANT lock on. SPID 73 is the data Collector, SPID 120 is the user MERGE


Besides the obvious, which is to improve the code or the way things are done, is there any way to stop the Data Collecting being blocked? I would have expected the design to be such that this can't happen.

Leo
Nothing in life is ever so complex that with a little work it can't be made more complex

How would you expect Data Collector to gather its information without occasionally running into a long-running query that has a lock. About the only way you could solve the problem is to either re-code that ugly MERGE to run a lot faster, or to configure Data Collector to not look at certain data. As I'm not familiar with Data Collector, I don't even know if that's possible, so maybe someone with more knowledge on it can respond. This is one of those times when reading your own signature is of value...


Steve
‌(aka sgmunson)
Smile Smile Smile
Health & Nutrition
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search