All Products
Search
Document Center

Database Autonomy Service:GetDeadLockDetail

Last Updated:Oct 21, 2025

Retrieves the detailed information for a single deadlock event.

Operation description

This API fetches the full details of a specific deadlock, including the transactions involved, the SQL statements, and the locks held and waited for. The deadlock can be from either a recent analysis or a full historical analysis. For more information, see Deadlock analysis.

Before you call this operation, ensure the following:

  • Supported engines:

    • For recent deadlock analysis: ApsaraDB RDS for MySQL, self-managed MySQL, PolarDB for MySQL, PolarDB-X 2.0.

    • For full deadlock analysis: ApsaraDB RDS for MySQL or PolarDB for MySQL with DAS Economy Edition or DAS Professional Edition enabled.

  • SDK version: Use the latest version of the Alibaba Cloud SDK.

  • Region: If you call the API via the SDK, set the region ID to cn-shanghai.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

hdm:GetDeadLockDetail

none

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

The ID of the database instance.

pc-bp1u5mas9exx7****

NodeId

string

No

The node ID.

Note

Required for PolarDB for MySQL cluster instances.

pi-bp16v3824rt73****

TextId

string

Yes

The ID of the deadlock text. This value is returned from the GetDeadLockHistory operation.

a0e390cd5aca9ae964448f040153****

Source

string

No

The source of the analysis task:

  • MANUAL or not specified: queries the recent deadlock analysis task.

  • AUTO: queries the full deadlock analysis task.

AUTO

Response elements

Element

Type

Description

Example

object

RequestId

string

The unique request ID.

9CB97BC4-6479-55D0-B9D0-EA925AFE****

Message

string

The response message.

Note
  • When the request is successful, Successful is returned.

  • When the request fails, error information (such as error codes) is returned.

Successful

Synchro

string

The reserved parameter.

None

Data

string

The returned data in JSON format:

  • accountId: the user ID.

  • textId: the deadlock text ID.

  • gmtModified: the time when the diagnosis was generated.

  • originText: the original deadlock text of LATEST DETECTED DEADLOCK or the original deadlock text in the error log.

  • deadlock: the deadlock details:

    • occurTime: the time when the deadlock occurred.

    • originTextId: the deadlock text ID.

    • rollbackTrxId: the ID of the rolled back transaction.

    • transactions:

      • deadlockIdInDB: the deadlock ID in the database.

      • ip: the access IP address.

      • queryId: the query ID.

      • queryType: the query type.

      • relatedTables: the related tables.

      • tableNamesString: the related tables.

      • sqlText: the SQL text.

      • threadId: the thread ID.

      • transactionId: the transaction ID.

      • trxIdInLock: the transaction ID in the deadlock.

      • userName: the database username.

      • waitLockIndexName: the name of the index for which the lock is waiting.

      • waitLockMode: the type of the lock that is waiting.

      • lockWait: the waiting lock.

      • holdLockIndexName: the name of the index for which the lock is held.

      • holdLockMode: the type of the lock that is held.

      • lockHold: the held lock.

    • trxNum: the number of transactions.

  • gmtCreate: the time when the diagnosis was created.

  • nodeId: the node ID.

  • uuid: the instance ID.

{ "accountId": "108************", "textId": "35303d12d52d29ba73bb************", "gmtModified": 1732712680000, "originText": "LATEST DETECTED DEADLOCK****", "deadlock": "{\"id\":0,\"occurTime\":1732687047000,\"originTextId\":\"35303d12d52d29ba73bb************\",\"rollbackTrxId\":\"2\",\"transactions\":[{\"deadlockIdInDB\":0,\"ip\":\"100.***.***.***\",\"lockWait\":\"index PRIMARY of table `das`.`students` trx id 15989454 lock_mode X locks rec but not gap waiting\",\"queryId\":\"386737457\",\"queryType\":\"updating\",\"relatedTables\":[\"`das`.`students`\"],\"sqlText\":\"update students set name=UUID() where id = 2 \",\"tableNamesString\":\"`das`.`students`\",\"threadId\":\"9194526\",\"transactionId\":\"15989454\",\"trxIdInLock\":1,\"userName\":\"das\",\"waitLockIndexName\":\"PRIMARY \",\"waitLockMode\":\"X locks rec but not gap waiting\"},{\"deadlockIdInDB\":0,\"holdLockIndexName\":\"PRIMARY \",\"holdLockMode\":\"X locks rec but not gap\",\"ip\":\"100.***.***.***\",\"lockHold\":\"index PRIMARY of table `das`.`students` trx id 15989451 lock_mode X locks rec but not gap\",\"lockWait\":\"index PRIMARY of table `das`.`students` trx id 15989451 lock_mode X locks rec but not gap waiting\",\"queryId\":\"386737566\",\"queryType\":\"updating\",\"relatedTables\":[\"`das`.`students`\"],\"sqlText\":\"update students set name=UUID() where id = 3 \",\"tableNamesString\":\"`das`.`students`\",\"threadId\":\"9194501\",\"transactionId\":\"15989451\",\"trxIdInLock\":2,\"userName\":\"das\",\"waitLockIndexName\":\"PRIMARY \",\"waitLockMode\":\"X locks rec but not gap waiting\"}],\"trxNum\":2}", "gmtCreate": 1732712680000, "nodeId": "pi-8****************", "uuid": "pc-8v***************" }

Code

string

The returned status code.

200

Success

string

Indicates whether the request was successful. Valid values:

  • true: The request was successful.

  • false: The request failed.

true

Examples

Success response

JSON format

{
  "RequestId": "9CB97BC4-6479-55D0-B9D0-EA925AFE****",
  "Message": "Successful",
  "Synchro": "None",
  "Data": "{\n    \"accountId\": \"108************\",\n    \"textId\": \"35303d12d52d29ba73bb************\",\n    \"gmtModified\": 1732712680000,\n    \"originText\": \"LATEST DETECTED DEADLOCK****\",\n    \"deadlock\": \"{\\\"id\\\":0,\\\"occurTime\\\":1732687047000,\\\"originTextId\\\":\\\"35303d12d52d29ba73bb************\\\",\\\"rollbackTrxId\\\":\\\"2\\\",\\\"transactions\\\":[{\\\"deadlockIdInDB\\\":0,\\\"ip\\\":\\\"100.***.***.***\\\",\\\"lockWait\\\":\\\"index PRIMARY of table `das`.`students` trx id 15989454 lock_mode X locks rec but not gap waiting\\\",\\\"queryId\\\":\\\"386737457\\\",\\\"queryType\\\":\\\"updating\\\",\\\"relatedTables\\\":[\\\"`das`.`students`\\\"],\\\"sqlText\\\":\\\"update students set name=UUID() where id = 2 \\\",\\\"tableNamesString\\\":\\\"`das`.`students`\\\",\\\"threadId\\\":\\\"9194526\\\",\\\"transactionId\\\":\\\"15989454\\\",\\\"trxIdInLock\\\":1,\\\"userName\\\":\\\"das\\\",\\\"waitLockIndexName\\\":\\\"PRIMARY \\\",\\\"waitLockMode\\\":\\\"X locks rec but not gap waiting\\\"},{\\\"deadlockIdInDB\\\":0,\\\"holdLockIndexName\\\":\\\"PRIMARY \\\",\\\"holdLockMode\\\":\\\"X locks rec but not gap\\\",\\\"ip\\\":\\\"100.***.***.***\\\",\\\"lockHold\\\":\\\"index PRIMARY of table `das`.`students` trx id 15989451 lock_mode X locks rec but not gap\\\",\\\"lockWait\\\":\\\"index PRIMARY of table `das`.`students` trx id 15989451 lock_mode X locks rec but not gap waiting\\\",\\\"queryId\\\":\\\"386737566\\\",\\\"queryType\\\":\\\"updating\\\",\\\"relatedTables\\\":[\\\"`das`.`students`\\\"],\\\"sqlText\\\":\\\"update students set name=UUID() where id = 3 \\\",\\\"tableNamesString\\\":\\\"`das`.`students`\\\",\\\"threadId\\\":\\\"9194501\\\",\\\"transactionId\\\":\\\"15989451\\\",\\\"trxIdInLock\\\":2,\\\"userName\\\":\\\"das\\\",\\\"waitLockIndexName\\\":\\\"PRIMARY \\\",\\\"waitLockMode\\\":\\\"X locks rec but not gap waiting\\\"}],\\\"trxNum\\\":2}\",\n    \"gmtCreate\": 1732712680000,\n    \"nodeId\": \"pi-8****************\",\n    \"uuid\": \"pc-8v***************\"\n}",
  "Code": "200",
  "Success": "true"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParams The request parameters are invalid.
403 NoPermission You are not authorized to do this action.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.