|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, February 19, 2013 1:46 PM
Points: 112,
Visits: 255
|
|
How to get the Deadlock Graph from the xml extracted from system_health extended event.
I'm using SQL Server 2008R2 SP2, and when I try to open the xdl file it says Failed to initialize deadlock control, key cannot be nul, Parameter name:Key
Thanks
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 7:22 AM
Points: 6,693,
Visits: 11,707
|
|
APA0876 (1/29/2013) How to get the Deadlock Graph from the xml extracted from system_health extended event. Retrieving Deadlock Graphs with SQL Server 2008 Extended Events By Jonathan Kehayias
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Yesterday @ 4:59 AM
Points: 242,
Visits: 879
|
|
In some circumstances the workaround in the linked article for the invalid xml in earlier builds of SQL Server won't work. I've come across a few situations where a bit more manipulation is required.
This what I use now:
declare @xml xml
select @xml = target_data from sys.dm_xe_session_targets join sys.dm_xe_sessions on event_session_address = address where name = 'system_health'
if (substring(cast (serverproperty('ProductVersion') as nvarchar(20)), 1, 5) = '10.00' and cast(substring(cast (serverproperty('ProductVersion') as nvarchar(20)), 7, 4) as int) < 2757) or (substring(cast (serverproperty('ProductVersion') as nvarchar(20)), 1, 5) = '10.50' and cast(substring(cast (serverproperty('ProductVersion') as nvarchar(20)), 7, 4) as int) < 1702) begin select cast ( replace ( replace ( replace ( replace ( replace ( replace(replace(replace(xev.xv.value ('(data/value)[1]', 'nvarchar(max)'), ' ','!£$%&'),'%&!£$',''),'!£$%&',' '), '<victim-list', '<deadlock><victim-list'), '<victim-list/>', '<victim-list>'), '<process-list>', '</victim-list><process-list>'), char(10), ''), '"> <victimProcess', '" /> <victimProcess') as xml) from (select @xml as tg) AS Data cross apply tg.nodes ('RingBufferTarget/event[@name="xml_deadlock_report"]') as xev (xv) end else begin select cast(xev.xv.value ('(data/value)[1]', 'nvarchar(max)') as xml) from (select @xml as tg) AS Data cross apply tg.nodes ('RingBufferTarget/event[@name="xml_deadlock_report"]') as xev (xv) end
 FREE DOWNLOAD www.sqlcopilot.com
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 7:22 AM
Points: 6,693,
Visits: 11,707
|
|
Which version of SQL are you on?
http://www.sqlservercentral.com/Forums/FindPost1003578.aspx
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, February 19, 2013 1:46 PM
Points: 112,
Visits: 255
|
|
Hi, We are on sql server 2008 R2 enterprose edition SP2
Thanks
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, February 19, 2013 1:46 PM
Points: 112,
Visits: 255
|
|
Hi, The script sent does not work either to show the deadlock graph when I save it as a xdl file and open it with SSMS it says: Failed to initialize deadlock control. There is an error in XML document (1,2) <deadlock xmlns="> was not expected
Thanks
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Yesterday @ 4:59 AM
Points: 242,
Visits: 879
|
|
Did you read the linked article from opc.three's first reply? It states in there that "you can't save this XML document as a .XDL file and open it graphically in Management Studio"
 FREE DOWNLOAD www.sqlcopilot.com
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 7:22 AM
Points: 6,693,
Visits: 11,707
|
|
This one was actually directed to you Richard, just wondering if you were on the latest build. Jonathan seemed to imply there might have been multiple rounds of fixes for the XML format issues.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Yesterday @ 4:59 AM
Points: 242,
Visits: 879
|
|
I'm using pretty much every build from the last few years 
I don't remember which build produced the xml that Jonathan's code couldn't handle, but I remember it was for cases where there is more than one deadlock victim.
Certainly since the builds that my script checks for I have seen no problems, though you're right about the incremental fixes from Microsoft - and there is still a size limit in the xml that can be returned I think.
 FREE DOWNLOAD www.sqlcopilot.com
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, May 10, 2013 2:49 PM
Points: 3,051,
Visits: 1,356
|
|
|
|
|