All Products
Search
Document Center

ApsaraDB RDS:Deadlocks

Last Updated:Mar 28, 2026

The DeadLock tab in ApsaraDB RDS for SQL Server shows deadlock events for your instance, including the transaction start time, session IDs, locked resources, and deadlock types. Use this information to identify and fix the SQL statements and transactions that cause deadlocks.

How it works

When a transaction modifies a resource, SQL Server locks that resource to block concurrent modifications and preserve data consistency.

A deadlock occurs when two transactions each hold a lock the other needs. For example, Transaction A locks Resource A and waits for Resource B, while Transaction B locks Resource B and waits for Resource A. Neither transaction can proceed, so SQL Server terminates one of them.

死锁

SQL Server selects the session to terminate based on rollback cost: it terminates the session whose transaction can be rolled back at the lowest cost, called the deadlock victim. For example, if a deadlock occurs between a SELECT session and an UPDATE session, SQL Server terminates the SELECT session because it is cheaper to roll back.

Key concepts

Deadlock types

ApsaraDB RDS for SQL Server detects the following deadlock types:

  • KeyDeadlock

  • ObjectDeadLock

  • RIDDeadlock

  • PageDeadlock

  • ComplieDeadlock

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

Lock modes

The lock mode applied to a resource depends on the type of access:

  • Shared (S): The resource can be read but not modified until the transaction releases the shared lock.

  • Update (U): Another transaction cannot modify the resource until it acquires an exclusive lock on the resource.

  • Exclusive (X): No other transaction can access the resource until the locking transaction releases the exclusive lock.

Prerequisites

Before you begin, ensure that:

  • Your RDS instance does not run SQL Server 2008 R2 with cloud disks

  • Your RDS instance resides in one of the following regions: China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Chengdu), China (Hong Kong), Singapore, or UAE (Dubai)

View deadlock details

  1. Go to the Instances page. In the top navigation bar, select the region where your RDS instance resides, then click the instance ID.

  2. In the left-side navigation pane, choose Autonomy Services > Lock Optimization.

DeadLock tab reference

Numbers of deadlocks

Displays the number of deadlocks over recent time ranges. Specify a time range to filter the results.

死锁数量

Deadlock trend

Displays the distribution of deadlock types over a time range.

死锁变化趋势
  • Set a start time and end time, then click Search. The time range cannot exceed 30 days.

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

  • Hover over a data point to see the deadlock types and counts at that time.

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

Deadlock details

死锁详细信息

Click the 加号 icon next to a deadlock record to expand the blocking and blocked session details.

FieldDescription
LastTranStartedTime when the transaction started in the session
SPIDSession ID
IsVictimWhether the session was terminated as the deadlock victim
LogUsedSize of transaction log generated in the session, in bytes
LockModeLock mode held by the session
WaitResourceDescDetails of the resource the transaction is waiting for
ObjectOwnedObject locked by the session
ObjectRequestedObject the transaction is attempting to lock
WaitResourceName of the resource the transaction is waiting for
HostNameHost where the transaction is running
LoginNameAccount used to run the transaction
StatusStatus of the transaction in the session
ClientAppClient that initiated the transaction
SQLTextSQL statement executed in the session. Click the statement to copy it for further analysis.

Click a deadlock record to open the Deadlock Diagram section.

Deadlock diagram

死锁关系图

Displays the relationships between the blocking and blocked sessions, along with details about the locked resources. Click Download to download the XDL file, then open it in SQL Server Management Studio (SSMS) to view the full deadlock graph.

What's next

What do I do if a deadlock occurs on an ApsaraDB RDS for SQL Server instance?