Troubleshooting Deadlocks
cjlotz
Posts: 45
Hi
I'm having trouble trying to pinpoint a deadlock issue raised by SQL Monitor. SQL Monitor only displays fragments of the queries that are deadlocked and I'm unable to locate the specific queries in the SQL Processes/Profiler trace views.
Here are the steps I'm following:
However, I find no occurence of the SQL fragment. My expectation would be that the trace should include the fragment but it does not.
Another issue with using the SQL fragment to locate the query is that the fragment doesn't include all the context (i.e. the values being inserted). This is problematic in searching the trace when we have 100 of the same queries executing with different values. Because the fragment doesn't include the values we can't determine the exact query that failed.
Thx
I'm having trouble trying to pinpoint a deadlock issue raised by SQL Monitor. SQL Monitor only displays fragments of the queries that are deadlocked and I'm unable to locate the specific queries in the SQL Processes/Profiler trace views.
Here are the steps I'm following:
-
Click on the Victim process for the Deadlock alert. This shows only a fragment of the query that was terminated (first 5 lines).
I then click on the SQL Processes/Profiler trace window to look at all the queries executed for the specific victim process.
I tried to find the specific query by first selecting the complete trace and pasting it in Notepad to do search for the text (
However, I find no occurence of the SQL fragment. My expectation would be that the trace should include the fragment but it does not.
Another issue with using the SQL fragment to locate the query is that the fragment doesn't include all the context (i.e. the values being inserted). This is problematic in searching the trace when we have 100 of the same queries executing with different values. Because the fragment doesn't include the values we can't determine the exact query that failed.
Thx
Comments
I'm having issues recreating this issue internally. I have created several deadlock alerts but each time the sql query fragment can also be found in the trace listing.
I did notice that when copy/pasting the trace into notepad that the search for the fragment didn't work for me due to it being pasted in with no space between the fragment and the date (as follows):
7 Jan 2011 11:06:22UPDATE ##17826ade WITH (PAGLOCK) SET col1 = 1
The trace presented should be 40 seconds of trace for that process, 20 seconds prior and 20 seconds after the deadlock occurrence. We get the fragment from SQL Server and are limited by what we can do here but in theory the fragment should appear in the trace.
What are the date/times displayed in the trace listing and do they cover the point in time that the deadlock occurred?
In the meantime, I have raised a couple of enhancement requests
SRP-3032 - Make it easier to locate the SQL query fragment in the trace listing
SRP-3033 - Investigate improving the query fragment to include more context.
Thanks
Chris
Test Engineer
Red Gate
Just to confirm - does SQL Server itself only send through the partial query fragment or is this a SQL Monitor issue?
Thx
We do have other reported issues along these lines:
http://www.red-gate.com/MessageBoard/vi ... hp?t=12473
We will be investigating and hopefully improving the trace collection for version 2.2.
Regards
Chris
Test Engineer
Red Gate
Old Version Log:
New Version Log:
You'll notice that in the new version it starts off with the parameters, thus not giving us the table that it occurs on.
With regard to the fragment. I've switched on tracing on SQL Server 2008, by issuing the following command: DBCC TRACEON (1222, -1)
In SQL Monitor I get this fragment:
If I look in the SQL Server Error Log I get the following:
You'll notice that it gives me the fragment that SQL Monitor prints out, but further down it gives me a bigger fragment of the query.
In Summary:
1. The old version of SQL Monitor gave us better information about the query that was involved in the deadlock. For inserts it gave us the first part of the query, where the table name is. In the new version it starts off with the Parameters.
2. Even though SQL Server prints out more information in the error log, this information is not available in SQL Monitor. It would be great to have it there too.
3. I've also confirmed that going to "SQL processes/Profiler trace" and looking for the SPID in question, I could not find the queries in the fragment anywhere in the list of statements for that SPID.
Regarding your summary points:
1. We are definitely looking to ensure that SQL Monitor presents as least as much information as our previous product (SQL Response)
2. I'll investigate this and potentially raise an enhancement request.
3. I'm worried about this as I can't reproduce it internally. The list of trace statements in SQL Monitor should have datetime values. Do these values coincide with the time of the deadlock occurrence in the SQL Server error log? I'm worried that we might be reading the wrong chunk of the trace file for some reason.
Thanks
Chris
Test Engineer
Red Gate