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


Retrieving Deadlock Graphs with SQL Server 2008 Extended Events


Retrieving Deadlock Graphs with SQL Server 2008 Extended Events

Author
Message
AnthonyR
AnthonyR
SSC Journeyman
SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)

Group: General Forum Members
Points: 75 Visits: 53
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.
shahgols
shahgols
SSC Eights!
SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)

Group: General Forum Members
Points: 933 Visits: 5738
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.



Jared Karney
Jared Karney
SSCarpal Tunnel
SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)SSCarpal Tunnel (5K reputation)

Group: General Forum Members
Points: 4964 Visits: 3694
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
PFE - Microsoft
SQL Know-It-All
How to post data/code on a forum to get the best help - Jeff Moden
shahgols
shahgols
SSC Eights!
SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)

Group: General Forum Members
Points: 933 Visits: 5738
Thank you Jared.



shahgols
shahgols
SSC Eights!
SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)

Group: General Forum Members
Points: 933 Visits: 5738
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.



hello mahesh
hello mahesh
SSC Rookie
SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)SSC Rookie (48 reputation)

Group: General Forum Members
Points: 48 Visits: 255
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
AnthonyR
AnthonyR
SSC Journeyman
SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)

Group: General Forum Members
Points: 75 Visits: 53
@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!
shahgols
shahgols
SSC Eights!
SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)SSC Eights! (933 reputation)

Group: General Forum Members
Points: 933 Visits: 5738
Many, many thanks!!! Great, in-depth explanation!



m60freeman
m60freeman
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 417
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.

AnthonyR
AnthonyR
SSC Journeyman
SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)

Group: General Forum Members
Points: 75 Visits: 53
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.
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