All Products
Search
Document Center

Database Autonomy Service:Deadlock analysis

Last Updated:Mar 28, 2026

Parsing raw InnoDB logs to diagnose deadlocks is time-consuming and requires deep familiarity with the InnoDB lock system. Database Autonomy Service (DAS) automates this process through its lock analysis feature, which visualizes deadlock relationships and traces the full transaction history without manual log parsing. DAS provides two modes: recent deadlock analysis, which captures the latest deadlock on demand, and full deadlock analysis, which continuously collects deadlock history from the instance error log.

The data shown in the screenshots is for demonstration only. Use your actual thread IDs and SQL statements when working with your instances.

Prerequisites

Before you begin, make sure that:

  • The target instance runs a supported database engine:

    ModeSupported engines
    Recent deadlock analysisRDS MySQL, self-managed MySQL, PolarDB for MySQL, PolarDB-X 2.0
    Full deadlock analysisRDS MySQL, PolarDB for MySQL
  • The instance is connected to DAS with a connection status of Normal Access. See Connect a database instance to DAS.

  • Alibaba Cloud Managed Services (formerly DAS Economy Edition) is enabled for the instance.

Important

Alibaba Cloud Managed Services (formerly DAS Economy Edition) is available only in some regions. For region availability, see Supported databases and regions by edition. To enable the service, see Manage Alibaba Cloud Managed Services (formerly DAS Economy Edition).

Recent deadlock analysis

Recent deadlock analysis captures the most recent deadlock log from SHOW ENGINE INNODB STATUS output. Each time you trigger an analysis, DAS processes the latest deadlock and saves the result. If multiple deadlocks have occurred since the last analysis, only the most recent one is captured.

Required parameters

Enable innodb_deadlock_detect on the instance before running an analysis.

This parameter is enabled by default on most instance types. Confirm with SHOW VARIABLES LIKE 'innodb_deadlock_detect'. On some instance types, this parameter cannot be changed.

To modify instance parameters:

Run a recent deadlock analysis

  1. Log on to the DAS console.

  2. In the left navigation pane, click Intelligent O&M Center > Instance Monitoring.

  3. Click the target instance ID to go to the instance details page.

  4. In the left navigation pane, click Lock Analysis, then click the Recent Deadlock Analysis tab.

  5. Click Create Analysis Task.

image.png

View deadlock details

  1. Select a time range to filter the diagnostic task list.

  2. In the task list, click View Details in the Details column.

    image.png

  3. A panel opens with three tabs:

    • View: A visual graph of the deadlock relationship. Click a transaction tile to see that transaction's details below the graph. image.png

    • List: A side-by-side comparison of the details of lock-holding transactions. image.png

    • Log: The raw LATEST DETECTED DEADLOCK section from SHOW ENGINE INNODB STATUS, useful for low-level debugging. image.png

Trace the full transaction history with SQL Explorer and Audit

Use the thread IDs from the deadlock analysis to look up every SQL statement the transactions executed — not just the statements involved in the lock conflict.

  1. In the left navigation pane of the instance, click SQL Explorer and Audit. On the Audit page, click Enable Advanced Query.

    image.png

  2. Set the time range to cover the period when the deadlock occurred, then search by the thread ID from the recent deadlock analysis.

    • Transaction 1: image.png

    • Transaction 2 (rolled back): image.png

Full deadlock analysis

Full deadlock analysis parses deadlock events from the instance error log every hour, building a historical trend of deadlock counts and preserving the details of each individual deadlock.

Required parameters

Enable the following parameters before using full deadlock analysis:

ParameterRequired for
innodb_deadlock_detectAll supported engines
innodb_print_all_deadlocksAll supported engines
log_error_verbosity = 3RDS MySQL only
innodb_deadlock_detect is enabled by default on most instance types. Confirm with SHOW VARIABLES LIKE 'innodb_deadlock_detect'. On some instance types, this parameter cannot be changed.

To modify instance parameters:

Cooldown period: If Alibaba Cloud Managed Services is enabled but the required parameters are not, DAS pauses full deadlock analysis for a 12-hour cooldown period. After the cooldown expires, DAS retries the analysis. If the parameters are still disabled, another 12-hour cooldown begins.

For example: an analysis task is scheduled at 11:12. DAS detects that a required parameter is disabled and starts a 12-hour cooldown. At 23:12, DAS retries. If the parameter is now enabled, analysis runs at 23:12 and continues every hour until the parameter is disabled or Alibaba Cloud Managed Services is turned off for the instance.

Important

Full deadlock analysis does not support deadlocks that contain the message: "TOO DEEP OR LONG SEARCH IN THE LOCK TABLE WAITS-FOR GRAPH, WE WILL ROLL BACK FOLLOWING TRANSACTION".

View the deadlock trend

  1. Log on to the DAS console.

  2. In the left navigation pane, click Intelligent O&M Center > Instance Monitoring.

  3. Click the target instance ID to go to the instance details page.

  4. In the left navigation pane, click Lock Analysis, then click the Full Deadlock Analysis tab.

  5. Select a time range to view the Deadlock Trend chart. The chart plots the deadlock count for the selected period.

    image.png

View deadlock details

  1. In the deadlock list, click View Details in the Details column.

    image.png

  2. A panel opens with the same View, List, and Log tabs as in recent deadlock analysis. The Log tab contains error logs related to the deadlock. For details on reading each tab, see View deadlock details in the recent deadlock analysis section.

    image

Trace the full transaction history with SQL Explorer and Audit

The procedure is the same as for recent deadlock analysis. See Trace the full transaction history with SQL Explorer and Audit in the recent deadlock analysis section.

What's next