Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««45678»»

Retrieving Deadlock Graphs with SQL Server 2008 Extended Events Expand / Collapse
Author
Message
Posted Tuesday, September 24, 2013 7:24 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, June 11, 2014 7:28 PM
Points: 41, Visits: 46
hello mahesh (9/17/2012)
We had couple of deadlock issues,
but nothing is captured with this query..

select XEventData.XEvent.value('(data/value)[1]', 'varchar(max)') as DeadlockGraph
FROM
(select CAST(target_data as xml) as TargetData
from sys.dm_xe_session_targets st
join sys.dm_xe_sessions s on s.address = st.event_session_address
where name = 'system_health') AS Data
CROSS APPLY TargetData.nodes ('//RingBufferTarget/event') AS XEventData (XEvent)
where XEventData.XEvent.value('@name', 'varchar(4000)') = 'xml_deadlock_report'


We had the same issues here as hello mahesh...

select @@version
Microsoft SQL Server 2008 (SP3) - 10.0.5512.0 (X64) Aug 22 2012 19:25:47 Copyright (c) 1988-2008 Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (VM)

I found that the issue was with this line:

cross apply TargetData.nodes ('//RingBufferTarget/event') as XEventData (XEvent)

Using either one of the following two lines returned the expected results:

cross apply TargetData.nodes ('/RingBufferTarget/event') as XEventData (XEvent)
cross apply TargetData.nodes ('RingBufferTarget/event') as XEventData (XEvent)

Hope this helps.
Post #1498100
Posted Thursday, September 26, 2013 12:42 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, August 21, 2014 2:00 PM
Points: 627, Visits: 4,978
Hi Jonathan, I read your article, but I am still unsure how to see the graphical view of the deadlock. The query returns several rows of xml data and when I click on one, it opens up the raw xml. How do I see the graph? Thanks.


Post #1499014
Posted Thursday, September 26, 2013 12:49 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, August 20, 2014 8:40 AM
Points: 2,692, Visits: 3,383
shahgols (9/26/2013)
Hi Jonathan, I read your article, but I am still unsure how to see the graphical view of the deadlock. The query returns several rows of xml data and when I click on one, it opens up the raw xml. How do I see the graph? Thanks.


When you click on one and the xml opens, save it with .xdl extension. Close it and reopen it.


Thanks,

Jared
SQL Know-It-All

How to post data/code on a forum to get the best help - Jeff Moden
Post #1499017
Posted Thursday, September 26, 2013 1:04 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, August 21, 2014 2:00 PM
Points: 627, Visits: 4,978
Thank you Jared.


Post #1499028
Posted Thursday, September 26, 2013 1:14 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, August 21, 2014 2:00 PM
Points: 627, Visits: 4,978
When I try to open the xdl file in SSMS 2012, I get:

Failed to initialize deadlock control.
Key cannot be null.
Parameter name: key

When I try to open it in SSMS 2008 R2, I get:

Failed to initialize deadlock control.
There is an error in XML document (1, 2).
<deadlock xmlns="> was not expected.

Any help would be appreciated.



Post #1499034
Posted Thursday, September 26, 2013 1:15 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Today @ 8:48 AM
Points: 16, Visits: 197
AnthonyR, I don't think there is a issue with my syntax, but it was with SSMS 2008 or older. Even your suggested change didn't work.

In SSMS 2012 version it works!

http://www.sqlskills.com/blogs/jonathan/graphically-viewing-extended-events-deadlock-graphs/

Thanks
Post #1499035
Posted Thursday, September 26, 2013 5:11 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, June 11, 2014 7:28 PM
Points: 41, Visits: 46
@shahgols: The Deadlock Graph visualizer in SSMS expects XDL (XML Deadlock List) files as output from SQL Profiler using the following technique: How to save deadlock graph events as .xdl file in SQL Server?

At least in the case of SQL Server 2008, the XML output from Extended Events using Jonathan's code is very similar, but not quite the same. Thankfully there are not too many modifications that need to be done:
1. The root node needs to be <deadlock-list>, one level above <deadlock>
2. The id attribute of the <victimProcess> tag needs to be copied into the victim attribute of the <deadlock> tag.
3. I don't know if this is necessary, but I've also been deleting the <victim-list>...</victim-list> tag block.

So you should transform your output from something like this:

<deadlock>
<victim-list>
<victimProcess id="process62a988" />
</victim-list>
<process-list>
...
</process-list>
<resource-list>
...
</resource-list>
</deadlock>

To something like this:

<deadlock-list>
<deadlock victim="process62a988">
<process-list>
...
</process-list>
<resource-list>
...
</resource-list>
</deadlock>
</deadlock-list>

Hope this helps!
Post #1499107
Posted Thursday, September 26, 2013 6:23 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, August 21, 2014 2:00 PM
Points: 627, Visits: 4,978
Many, many thanks!!! Great, in-depth explanation!


Post #1499123
Posted Wednesday, June 11, 2014 8:35 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Yesterday @ 6:35 PM
Points: 1, Visits: 92
When I execute the SQL posted by Grasshopper that starts with:

IF OBJECT_ID('tempdb..#ZZ_DeadlockEvents2008') IS NOT NULL Drop Table #ZZ_DeadlockEvents2008


in a Microsoft SQL Server 2012 (SP1) - 11.0.3128.0 (X64) instance, I get:

Msg 402, Level 16, State 1, Line 24
The data types datetime and time are incompatible in the add operator.
Post #1579659
Posted Wednesday, June 11, 2014 7:30 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, June 11, 2014 7:28 PM
Points: 41, Visits: 46
m60freeman (6/11/2014)
When I execute the SQL posted by Grasshopper that starts with:

IF OBJECT_ID('tempdb..#ZZ_DeadlockEvents2008') IS NOT NULL Drop Table #ZZ_DeadlockEvents2008


in a Microsoft SQL Server 2012 (SP1) - 11.0.3128.0 (X64) instance, I get:

Msg 402, Level 16, State 1, Line 24
The data types datetime and time are incompatible in the add operator.


Since you don't have 24 lines in your example query I'd guess that you probably have a problematic DDL Trigger generating the error.
Post #1579863
« Prev Topic | Next Topic »

Add to briefcase «««45678»»

Permissions Expand / Collapse