There may be thousands of events displayed, but right-click on the data viewer and select Filter by this Value (or use the Extended Events | Filter menu) to set up a filter on the name column so the viewer displays an event only if it " Contains" the value " deadlock".īy clicking on an xml_deadlock_report event in the data viewer, we can see the deadlock graph, either as XML ( Details tab) or in graphical form ( Deadlock tab). see Listing 1 of Gail Shaw's article), or using the Extended Events UI target data viewer in SSMS (SQL Server 2012 and later only), as shown in Figure 2.įigure 2 – View Target Data from the SQL Server Management Studio UI You can retrieve it retrospectively, in response to a 1205 error alert, either by running a T-SQL/XPath query (e.g. On SQL Server 2008 or later, the system_health extended event session is enabled by default, and automatically captures the deadlock graph. With SQL Server 2008 and later there are much better ways. Only use this technique if you have no other choice. As you can see, SQL Server fills the error log with a lot of information, and there is also a lot of manual work for the DBA still to do here, in working out the sessions and resources (tables, indexes) involved in the deadlock. However, unless you have the traceflag enabled permanently, you'd need to enable it and wait for the deadlock to recur. Figure 1 shows the error log contents, highlighting the process selected as the deadlock victim then above it the deadlock graph output.įigure 1 – the error log, with the victim of a deadlocked process highlighted in red There was a time, when they only way to get the deadlock graph was to enable traceflag 1222 (or 1204 on SQL 2000) to capture it into the error log. This reveals the deadlocked sessions, what statements were being run, the database, objects and pages on which the sessions were deadlocked, and more. If you suspect deadlocks are occurring on your SQL Server instances, what can you do? We'll review three approaches to their detection and resolution, each of which involves retrieving from SQL Server the information describing the deadlock, namely the deadlock graph. Resolving deadlocks with SQL Server performance monitoring DBAs must know immediately when one occurs, by alerting on 1205 errors, and then need at their fingertips all of the information necessary to troubleshoot the deadlock and ensure that it doesn't recur. Nevertheless, deadlock errors cause resource contention, disruption and delay, and cannot be ignored. It should also have retry logic that allows the victim transaction to rerun, once the deadlock clears. Any application code that issues database queries should be equipped with error handling that deals with the problem gracefully, and sends the calling client a "user friendly" message. Ideally, no user should ever be confronted with error message 1205, even if a deadlock does occur. It means that the other sessions may proceed, but that is little comfort to the hapless victim, and if that victim happens to be a session running a critical business process, then it may soon be of little comfort to the DBA. It automatically chooses one of the sessions as the 'victim', kills it and rolls back its transaction. The result is a 'circular chain' where no session can complete, and so SQL Server is forced to intervene to clear up the mess. Two or more sessions were waiting to acquire a lock on a resource already locked by another session in the same locking chain. Transaction (Process ID 62) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. What are SQL Server Deadlocks & How Do You Fix Them | Redgate Skip to content
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |