Locking is required for concurrent operations of relational databases to prevent data inconsistency and loss. However, locking impairs the performance of databases. Moreover, the locking process is often complicated. Deadlocks occur when concurrent processes compete for locks on shared resources. That is, one process holds a lock that another process requests while the second process holds a lock that the first process requests. Without accessing these shared resources, the processes cannot proceed. The database management system then aborts and rolls back one of the two processes so that the other process can continue. Addressing deadlocks requires tuning of applications, databases, and systems. When deadlocks are a persistent problem, changes in the design of applications and databases may be needed.
Monitor, alert, diagnose, and report on deadlocks with SQL Diagnostic Manager for SQL Server. In particular, view deadlocks for session and query performance, analyze locked and blocked sessions with deadlocks, and detect deadlocks with prescriptive analysis. Also, access deadlock metrics for managed cloud instances, display deadlocks in the mobile console, and set activity monitor options for deadlocks.
Monitor Deadlocks by Setting Server Configuration Properties
The ‘Server Configuration Properties’ view provides the current configuration settings for each of the monitored SQL Server instances. When selecting the ‘Server Configuration Properties’ view, SQL Diagnostic Manager displays a grid containing each of the settings for all monitored SQL Server instances. This information is updated each time the ‘Collection Service’ of SQL Diagnostic Manager runs. Some cells allow making changes on this view while other views are managed in other areas in SQL Diagnostic Manager that are accessible by double-selecting the cell to change. The ‘Server Configuration Properties’ view contains 38 properties including:
- ‘Activity Monitor Enabled’ that displays whether monitoring of non-query activities is enabled. The monitoring of non-query activities captures ‘autogrow’ events, deadlocks, and blocks. For more information about this setting, refer to the section ‘Set activity monitor options’.
- ‘Deadlock Monitoring’ that displays the current state of deadlock monitoring and that raises alerts for deadlocked sessions on monitored SQL Server instances. Deadlock monitoring depends on enabling the monitoring of non-query activities in the ‘Activity Monitor’ window. For more information about this setting, refer to the section ‘Set activity monitor options’.
Refer also to the product documentation ‘Server Configuration Properties’.
Access Deadlock Metrics for Managed Cloud Instances
After initially installing SQL Diagnostic Manager, add your SQL Server instances. The ‘Add Servers’ wizard adds the SQL Server instances to monitor. The wizard configures all common options to use for monitoring SQL Server collection settings and alerts, and apply alert templates. When adding several SQL Server instances and configuring the same alert thresholds on each SQL Server instance, consider setting up alert templates before adding SQL Server instances. SQL Diagnostic Manager recognizes when any of the added SQL Server instances are hosted on the cloud.
Use the ‘Select Cloud Providers for the Added Servers’ window to choose cloud providers for monitored SQL Server instances that are hosted on the cloud. SQL Diagnostic Manager displays a wide range of information collected for monitored SQL Server instances hosted on Amazon RDS and Microsoft SQL Azure. For monitored SQL Server instances hosted on Amazon RDS, SQL Diagnostic Manager collects 101 metrics from Amazon RDS. Of these metrics, in the SQL Diagnostic Manager area of ‘Sessions -> Summary’, one of the nine metrics that it collects for Amazon RDS is ‘Lock Statistics -> Deadlocks’. However, for monitored SQL Server instances hosted on Microsoft SQL Azure, SQL Diagnostic Manager does not gather 92 metrics. Of these metrics, in the SQL Diagnostic Manager area of ‘Sessions > Summary’, one of the six metrics that it does not collect for Microsoft SQL Azure is ‘Deadlocks’.
Refer also to the product documentation ‘Metric availability for instances hosted on the cloud’.
Chart Deadlocks for Sessions Information
The ‘Sessions’ tab of the single instance dashboard displays key diagnostic statistics for sessions on SQL Server instances and contains the Overview and Session Graphs views.
The ‘Sessions > Sessions Graphs’ tab contains three charts including the ‘Blocked Sessions’ chart that lists all ‘Blocked Sessions’, ‘Lead Blockers’, and ‘Total Deadlocks’ for each SQL Server instance. This chart displays blocks as they occur.
Refer also to the product documentation ‘View your SQL Server sessions information’.
View Deadlocks for Queries Information
The ‘Queries’ tab of the single instance dashboard lists each event that occurs in the ‘Query Monitor’ and displays query data in multiple ways and get a handle on query performance in the environment.
The ‘View Selection’ of the ‘Main Query’ view provides a variety of views to explore query data. One of the available eight views is Deadlocks.
The list view displays all matching objects for the view selection and grouping in the ‘Main Query’ view. The options that are available are ‘Application’ list, ‘Database’ list, ‘User’ list, ‘Client’ list, and ‘Query Signature’ list.
In the ‘View Selection’ of the ‘Main Query’ view, select ‘Group by Application’, ‘Group by Database’, ‘Group by User’, ‘Group by Client’, and ‘Group by Query Signature’ to display the ‘Application’ list, ‘Database’ list, ‘User’ list, ‘Client’ list, and ‘Query Signature’ list, respectively. The lists display 23 types of information including Average Deadlocks and Total Deadlocks.
Display Deadlocks in Mobile Console
The mobile console of SQL Diagnostic Manager helps to diagnose and fix SQL Server performance issues at any time from smartphones and other mobile devices. One of the eight options that are available through the dashboards of the mobile console is key resource metrics. The ‘Resources’ view provides access to the key metrics needed to monitor for optimal resource performance. View the current value of these metrics and plot them from now up to 12 hours in the past. These charts identify performance patterns and unexpected peaks in activity.
The ‘Resources’ view contains five filters including the ‘Session’ filter. The ‘Session’ filter presents key metrics representing the most important performance indicators for sessions connected to this SQL Server instance. For ‘Blocked Sessions’ the filter displays ‘Block Sessions (number of)’, ‘Lead Blockers (number of)’, and ‘Total Deadlocks (number of)’.
Refer also to the product documentation ‘Navigate SQLDM Mobile Dashboards’.
Track Sessions Performance via Deadlocks
The ‘Dashboard’ view of the ‘Overview’ tab contains a graphical representation of the activity on the SQL Server instance. This view not only displays the status of the SQL Server instance, but it diagnoses where problems originate. The ‘Dashboard’ view consists of panels that include additional information for specific metrics in chart form. Select particular metrics to drill down for more detailed information. One of the 13 panels is the ‘Sessions’ panel that includes session-specific data items.
The ‘Sessions’ panel tracks the performance of active and blocked sessions running on monitored SQL Server instances. Unexpected spikes in the number of concurrent blocked sessions may warn about the beginning of serious performance issues. Chronically high blocked and deadlocked sessions are a significant performance concern. The ‘Activity and Blocking’ chart shows the total number of active sessions on monitored SQL Server instances and any blocking and deadlocks that may occur between sessions. Four metrics are essential, including ‘Total Deadlocks’ that is important because it indicates the total number of deadlocks on the SQL Server instance. Deadlocks have no lead blockers and are circular in nature. Three alerts are available, including the ‘Total Deadlocks Alert’.
Refer also to the product documentation ‘Sessions panel’.
Use the ‘Monitored SQL Server Properties’ window to edit the monitoring settings of SQL Diagnostic Manager for the registered SQL Server instance. The Monitored SQL Server Properties window includes the 14 tabs including the ‘Activity Monitor’ that enables and disables monitoring of non-query activities and sets the options for the ‘Activity Monitor’.
The ‘Activity Monitor ‘window enables and disables monitoring of non-query activities. When enabling the ‘Activity Monitor’, select the settings to use. Three types of non-query events are captured, including ‘Deadlocks (SQL 2005+)’.
Capturing deadlock information allows the associated deadlock alert to provide details on deadlocked processes on the ‘Alerts’ view. Deadlock monitoring depends on the ‘Activity Monitor’. To access this information, check ‘Enable the Activity Monitor and Capture deadlocks (SQL 2005+)’ in the ‘Activity Monitor’ window.
The ‘Blocked Process’ report is a ‘SQL Server Profiler’ event. This event helps identify blocking issues and provides relevant information to solve these issues. In SQL Diagnostic Manager, take advantage of this feature by setting the blocked process threshold value according to what is needed. When this option is enabled, the blocked process threshold value is automatically set to 30 (seconds) but can be modified as desired.
Since collecting information about blocked processes in SQL Server is resource-intensive, IDERA recommends to set the blocked process threshold value to at least 5 (seconds), and the deadlock monitor runs constantly. For more information on this topic, see the Microsoft document ‘Increase and Disable Blocked Process Threshold’.
Refer also to the product documentation ‘Set activity monitor options’.
The ‘Sessions’ tab contains the following views:
- ‘Summary’ view to view charts for each Sessions statistic.
- ‘Details’ view to create charts with the specific data items that are needed.
- ‘Locks’ view to create charts based on each lock present on SQL Server instances.
- ‘Blocking’ view to create charts specific to all ‘Blocking’ sessions.
The ‘Sessions’ tab provides the following options:
- The ability to diagnose performance bottlenecks caused by blocking and locked sessions.
- The ability to trace specific sessions to see why the session may be blocking and locked.
- The ability to kill sessions to improve system performance.
Associated with the ‘Sessions’ tab are nine alerts including the ‘Deadlock’ alert when two processes are waiting for resources held by the other process.
Refer also to the product documentation ‘Monitor sessions’.
Analyze Locked Sessions with Deadlocks
On the ‘Locks’ view, see which problem locks are causing data availability problems and unacceptable responses. By combining the information provided on the ‘Problem Locks’ view (including the type of Lock) with the ‘Lock Statistics: Waits’ chart on the ‘Sessions Summary tab’, pinpoint, correct, and reschedule automated applications that cause extensive locking of rows, tables, and databases. Use the drop-down list in the chart title to select charts that include Deadlocks. Right-select any of these charts to print, save as image and export them to Microsoft Excel. Also, select ‘Toolbar’ for advanced customization options such as changing the chart color scheme and the type of chart shown.
Refer also to the product documentation ‘Analyze locked sessions’.
Analyze Blocked Sessions with Deadlocks
The ‘Blocking’ view provides blocking trees, along with the lead blockers, for each SQL Server instance. Lead blockers are sessions that block at least a single session, which can then block other sessions. Navigate through the blocking tree to find sessions that cause blocks, and then either trace sessions to find out what is causing the blocks or stop the session to have it removed. To trace blocked sessions and lead blockers select them from the list and select ‘Trace Session’. To stop blocked sessions, and lead blockers, select them from the list and select ‘Kill Session’.
Deadlocks have no lead blockers and are circular in nature. For this reason, SQL Diagnostic Manager does not display deadlocks in the ‘Blocking Tree’ but does display instances of deadlocks in the ‘Blocking Chart’. Also, SQL Diagnostic Manager does not count self-blocking sessions as blocked and blocking sessions.
The ‘Blocking’ chart displays the number of blocked sessions, lead blockers, and total deadlocks at given points in time. The total deadlocks represent the total number of deadlocks that have occurred since the last time since refreshing the pane. Right-select the chart to print, save as image, and export this data to Microsoft Excel. Also, select ‘Toolbar’ for advanced customization options, such as changing the chart color scheme and the type of chart shown.
The ‘Deadlock Sessions Report’ displays deadlock sessions information. In the ‘Alert’ view, access the ‘Deadlock Sessions Report’ by selecting the ‘Show Block Details’ option in the right-select context menu. Also access the same information on the ‘Blocking View’ by selecting specific SQL Server instances, pointing to ‘Sessions’, and then selecting the ‘Blocking’ ribbon.
Essential information provided for deadlock sessions includes the deadlock process details ‘Session ID’, ‘Status’, ‘Host Name’, ‘User Name’, ‘Execution Context’, ‘Application’, ‘Database’, ‘Last Batch Started’, ‘Last Batch Completed’, ‘Last Transaction Started’, ‘Transaction ID’, ‘Transaction Name’, ‘Open Transactions’, ‘Wait Time (ms)’, ‘Wait Type’, and ‘Wait Resource’. This feature exports statistics in deadlock eXtensible Markup Language (XML) (XDL) format.
To retrieve the deadlock sessions report for SQL Diagnostic Manager, select the ‘Non-Query activities > Capture deadlocks (SQL 2005+)’ checkbox in the ‘Activity Monitor Tab’.
Refer also to the product documentation ‘Analyze blocked sessions’.
Detect Deadlocks with Prescriptive Analysis
In SQL Diagnostic Manager, run prescriptive analyses on specific SQL Server instance to identify and resolve SQL Server performance problems.
In the ‘Monitored SQL Server Properties’ window, in the ‘Analysis Configuration’ tab, schedule prescriptive analyses of SQL Server instances and configure analysis options.
In particular, specify analysis options, schedule analyses, select categories, and use advanced analysis configuration options. When configuring the analysis, select any combination of performance categories to focus the investigation. Each category contains a set of performance metrics and their related recommendations. By picking categories, identify which SQL Server areas are of most concern. For use in the detailed analysis, on the ‘Select’ categories section, select a single and more of the five performance categories that include ‘Activity’. The ‘Activity’ category includes five options including ‘Deadlocks’ that detects any deadlocks on the SQL Server instance.
Refer also to the product documentation at ‘Performance categories’.
Report on Deadlocks
The ‘Reports’ view creates reports to analyze current and historical performance and statistical data. SQL Diagnostic Manager provides three types of comprehensive reports including the ‘Monitor’ reports along with the ability to create custom reports.
Monitor reports display overview information for the monitored SQL Server instances and the virtual machines on which the monitored SQL Server instances are running. Also, oversee overall activity in the SQL Diagnostic Manager environment through the ‘Activity Monitor’ reports. SQL Diagnostic Manager provides three ‘Monitor’ reports including ‘Server Monitor’ reports. ‘Server Monitor Reports’ provide an overview of monitored SQL Server instances. SQL Diagnostic Manager provides seven ‘Server Monitor Reports’ including the ‘Deadlock Report’. The Deadlock Report analyzes deadlocks on SQL Server instances. By analyzing, better determine where deadlocks are occurring and what changes can have the most significant performance impact.
The Deadlock report analyzes deadlocks on SQL Server instances. By analyzing the deadlocks, better determine where deadlocks are occurring and investigate the changes can have the most significant performance impact. The report filters the data by ‘Instance Name’, followed by ‘Application Name’, ‘Database Name’, ‘SQL Statement’, ‘Collection Date’, ‘XDL Data’ (deadlock XML — eXtensible Markup Language), ‘Deadlock ID’, ‘Login Name’, and ‘Host Name’. This report lists all deadlock occurrences historically and in detail.
Log Flushes Metric versus Deadlocks
SQL Diagnostic Manager collects some SQL Server and operating system performance metrics to monitor, alert, and report on system health. SQL Diagnostic Manager provides 44 metrics including ‘Log Flushes’. The ‘Log Flushes (Per Second)’ metric reads ‘LOG FLUSHES/SEC’ from the ‘sysperfinfo’ system table. Each time data changes, SQL Server writes the changes to the log cache that resides in memory. Under certain conditions, SQL Server flushes this log cache to disk. These situations include commits and rollbacks of explicit and implicit transactions.
With OnLine Transaction Processing (OLTP) systems that run relatively small transactions (on average, less than 40 rows added, changed, and deleted per transaction), the number of ‘Log Flushes ‘should not exceed SQL Batches by more than 40% during periods of high activity. When exceeding this percentage, then one of six abnormal conditions exists whereby ‘Deadlocks’ and ‘Lock Timeouts’ are causing some transactions to roll back and execute ‘ROLLBACK TRANSACTION’ statements.
Refer also to the product documentation ‘Log Flushes (Per Second)’.
Alert on Deadlocks
SQL Diagnostic Manager offers numerous alerts to successfully monitor and warn about SQL Server instances and availability groups. Proper configuration is key to ensure receiving alerts only on those metrics that fall outside the typical performance of the environment. SQL Diagnostic Manager provides 106 metric alerts including ‘Deadlock’.
The ‘Deadlock’ alert indicates that a deadlock occurred on the monitored SQL Server instance. For this alert to display, enable monitoring of non-query activities with the capturing of deadlock events. Deadlocks occur when processes attempt to access resources that the others hold locks on. Neither task can complete because both processes are trying to lock the same resource. SQL Server chooses a single and more deadlock to terminate so that processing can continue.
When ‘Deadlock’ alerts occur, check the ‘Alerts’ view in SQL Diagnostic Manager and select a deadlock alert. The ‘SPID’ (Server Process Identifier), ‘Hostname’, ‘Login Name’, ‘Client Application’, and ‘Database’ are listed. For more information, select ‘Show Deadlock Details’. This information helps with diagnosing the problem application and includes the option to export deadlock data to view in SQL Server Management Studio and SQL Server Profiler.
Refer also to the product documentation ‘Deadlock alert’.
Add Deadlock Alert to Alert Response Bundles
Use SQL Diagnostic Manager to configure alerts to inform and warn about approaching issues with SQL Server instances. Create alert response bundles for related alerts. The alert response bundle contains individual alert information for several alerts, summarized and delivered through only a single message. A total of 27 alerts divided into six categories are compatible with the alert response bundles features. The six categories include ‘Blocking and Deadlocks’ with three compatible alerts that include the ‘Deadlock’ alert.
Refer also to the product documentation ‘Create alert response bundles’.
Default Alert Identifier for Deadlocks
SQL Diagnostic Manager includes functionality aimed at the more advanced user who wants to manage these features without contacting IDERA Support for assistance. These advanced topics include six actions including understanding default alert identifiers. The 130 default alert identifiers include:
A deadlock occurred on the monitored server. Enable the ‘Activity Monitor > Capture deadlocks (SQL 2005+)’ checkbox for this alert to function.
Refer also to the product documentation ‘Default alert IDs’.
View the infographic “Why Use SQL Diagnostic Manager”, browse the datasheet read a case study, download a fully functioning 14-day trial, request a one-on-one demonstration, and request a price quotation.