All Products
Search
Document Center

Database Autonomy Service:View the deadlock statistics of an ApsaraDB RDS for SQL Server instance

Last Updated:Mar 28, 2026

Deadlocks in ApsaraDB RDS for SQL Server can be difficult to diagnose from application logs alone. Database Autonomy Service (DAS) provides the Lock Optimization feature, which records every deadlock event and lets you trace the exact SQL statements, sessions, and resources involved — giving you the data needed to identify root causes and reduce recurring deadlocks.

This topic walks you through the full diagnostic workflow: navigate to the deadlock statistics, read the trend data to spot patterns, expand session details to find the problem queries, and use the deadlock diagram to understand lock relationships.

Limitations

Instances running SQL Server 2008 R2 with standard SSDs or enhanced SSDs (ESSDs) are not supported.

How it works

When a transaction modifies a resource, SQL Server locks that resource to prevent conflicting changes from concurrent transactions. A deadlock occurs when two or more transactions each hold a lock the other needs. Deadlock

SQL Server resolves the deadlock by terminating the transaction that is least expensive to roll back. If your application receives that termination, it must resubmit the transaction.

DAS runs an internal deadlock monitor thread that periodically scans your RDS instance. When a deadlock is detected, DAS evaluates the blocking and blocked sessions and terminates the session in which the transaction can be rolled back at a lower cost than the other session. For example, if a deadlock occurs between a session that executes the SELECT statement and a session that executes the UPDATE statement, DAS terminates the SELECT session because rolling it back costs less. DAS then records the event so you can review it from the DeadLock tab.

Deadlock types

DAS can detect and classify the following deadlock types:

  • KeyDeadlock

  • ObjectDeadLock

  • RIDDeadlock

  • PageDeadlock

  • ComplieDeadlock

For details on each type, see Lock granularity and hierarchies.Lock granularity and hierarchies

Lock modes

SQL Server uses the following lock modes to control how concurrent transactions access the same resource:

ModeDescription
Shared (S)After a transaction acquires a shared lock, the resource can be read but not modified until the lock is released.
Update (U)After a transaction acquires an update lock, another transaction cannot modify the resource until it acquires an exclusive lock on it.
Exclusive (X)After a transaction acquires an exclusive lock, no other transaction can access the resource until the lock is released.

For details, see Lock modes.Lock modes

View deadlock statistics

  1. Log on to the DAS console.

  2. In the left-side navigation pane, click Instance Monitoring.

  3. Find the target instance and click its instance ID to open the instance details page.

  4. In the left-side navigation pane, click Lock Optimization. On the Lock Optimization page, click the DeadLock tab.

  5. On the DeadLock tab, review the deadlock statistics described in the sections below.

DeadLock tab reference

Numbers of deadlocks

死锁数量

Displays the total number of deadlocks that occurred across different time periods.

Deadlock trend

死锁变化趋势

Displays a time-series breakdown of deadlock types. Use the following controls to query deadlock data:

  • Set a start time and end time, then click Search to view deadlocks within that range.

    Note

    The time range cannot exceed 30 days.

  • Click Last 24 Hours, Last 7 Days, or Last Month to jump to a preset range.

  • Hover over a point in the trend chart to see the types and counts of deadlocks at that timestamp.

  • Use the 图标 icons in the upper-right corner to change the chart display style or download the chart.

Deadlock details

死锁详细信息

Lists all recorded deadlock events. Click the 加号 icon to the left of a record to expand the blocking and blocked session details.

Each session entry includes the following fields:

FieldDescription
LastTranStartedThe time the transaction started in this session.
SPIDThe session ID.
IsVictimWhether this session was terminated as the deadlock victim.
LogUsedThe size of transaction log generated in this session, in bytes.
LockModeThe lock mode held by this session. See Lock modes.
WaitResourceDescDetails of the resource this session is waiting to acquire.
ObjectOwnedThe object currently locked by this session.
ObjectRequestedThe object this session is requesting to lock.
WaitResourceThe name of the resource this session is waiting for.
HostNameThe host running the transaction in this session.
LoginNameThe account used to run the transaction.
StatusThe current status of the transaction.
ClientAppThe client application that initiated the transaction.
SQLTextThe SQL statement executed in this session. Click the statement to open it in a window where you can copy it for further analysis.

Deadlock diagram

死锁关系图

Click any deadlock record in the Deadlock details section to load its deadlock diagram here. The diagram shows the relationships between the blocking and blocked sessions and the details of each locked resource.

Click Download to save the diagram as an XDL file. The XDL file contains the full deadlock details in XML format, which you can open in SQL Server Management Studio (SSMS) for deeper analysis. For more information, see Download SQL Server Management Studio (SSMS).

What's next

After identifying the deadlock sessions and SQL statements:

  1. Copy the SQLText from the victim or blocking session. Examine its execution plan to find missing indexes or inefficient access patterns that increase lock hold time.

  2. If deadlocks recur, reduce transaction scope, adjust the order in which transactions acquire locks, or add indexes to minimize lock contention.