获取MySQL实例死锁信息
更新时间:2024-11-15
接口描述
获取MySQL实例 最近一次死锁信息
权限说明
鉴权认证机制的详细内容请参见鉴权认证。
请求结构
GET /v{version}/diagnosis/mysql/deadlock/latest?appId=appId&nodeId=nodeId HTTP/1.1
Host: dbsc.bj.baidubce.com
Authorization: authorization string
请求头域
除公共头域外,无其它特殊头域。
请求参数
参数名称 | 类型 | 必选 | 参数位置 | 描述 |
---|---|---|---|---|
version | string | 是 | Path参数 | API版本号 |
appId | string | 是 | Query参数 | 实例ID |
nodeId | string | 否 | Query参数 | 节点ID |
响应头域
除公共头域外,无其它特殊头域。
响应参数
参数名称 | 类型 | 描述 |
---|---|---|
metaInfo | object |
死锁元信息 |
deadLockId | string | 死锁ID |
timestamp | datetime | 生成时间 |
rawContent | string | 原始死锁信息 |
transactionLocks | List |
死锁事务信息 |
MysqlDeadLockMeta
参数名称 | 类型 | 描述 |
---|---|---|
duration | integer | 事务持续时间 |
hostname | string | 主机名 |
ip | string | IP地址 |
locks | List |
死锁锁信息 |
MysqlDeadLockTransaction
参数名称 | 类型 | 描述 |
---|---|---|
database | string | 数据库名 |
heapNo | integer | 堆号 |
index | string | 索引名 |
isPrediction | boolean | 是否预测生成 |
lockMode | string | 锁模式 |
lockType | string | 锁类型 |
pageNo | integer | 页号 |
recordLockType | string | 记录锁类型 |
spaceId | integer | 空间ID |
table | string | 表名 |
waitHold | string | 等待/持有 |
query | string | 查询语句 |
threadID | integer | 线程ID |
trxId | string | 事务ID |
trxSeq | integer | 事务序号 |
trxTime | string | 事务时间 |
user | string | 用户名 |
victim | integer | 是否被Kill0-否1-是 |
请求示例
GET /v1/diagnosis/mysql/deadlock/latest?appId=rds-0mxm0cTI&nodeId=rds-0mxm0cTI HTTP/1.1
Host: dbsc.bj.baidubce.com
Content-Type: application/json
Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2023-07-11T11:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
响应示例
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
x-bce-request-id: d8752367-38e8-45e4-b4c7-e53be3137ce5
{
"transactionLocks": [
{
"trxSeq": 1,
"trxId": "1536028",
"trxTime": "2024-10-18T02:54:12Z",
"duration": 86,
"ip": "",
"hostname": "localhost",
"threadID": 5537930,
"user": "_root",
"query": "select * from deadlock where id=2 for update",
"victim": 0,
"locks": [
{
"lockType": "RECORD",
"lockMode": "X",
"database": "db1",
"table": "deadlock",
"index": "PRIMARY",
"recordLockType": "LOCK_REC_NOT_GAP",
"spaceId": 2256,
"pageNo": 3,
"heapNo": 3,
"waitHold": "WAIT",
"isPrediction": false
},
{
"lockType": "RECORD",
"lockMode": "X",
"database": "db1",
"table": "deadlock",
"index": "PRIMARY",
"recordLockType": "LOCK_REC_NOT_GAP",
"spaceId": 2256,
"pageNo": 3,
"heapNo": 2,
"waitHold": "HOLD",
"isPrediction": true
}
]
},
{
"trxSeq": 2,
"trxId": "1536052",
"trxTime": "2024-10-18T02:55:21Z",
"duration": 17,
"ip": "",
"hostname": "localhost",
"threadID": 5538800,
"user": "_root",
"query": "select * from deadlock where id=1 for update",
"victim": 1,
"locks": [
{
"lockType": "RECORD",
"lockMode": "X",
"database": "db1",
"table": "deadlock",
"index": "PRIMARY",
"recordLockType": "LOCK_REC_NOT_GAP",
"spaceId": 2256,
"pageNo": 3,
"heapNo": 3,
"waitHold": "HOLD",
"isPrediction": false
},
{
"lockType": "RECORD",
"lockMode": "X",
"database": "db1",
"table": "deadlock",
"index": "PRIMARY",
"recordLockType": "LOCK_REC_NOT_GAP",
"spaceId": 2256,
"pageNo": 3,
"heapNo": 2,
"waitHold": "WAIT",
"isPrediction": false
}
]
}
],
"metaInfo": {
"timestamp": "2024-10-18T02:55:38Z",
"deadLockId": "7fa0d07a5700"
},
"rawContent": "------------------------\nLATEST DETECTED DEADLOCK\n------------------------\n2024-10-18 10:55:38 7fa0d07a5700\n*** (1) TRANSACTION:\nTRANSACTION 1536028, ACTIVE 86 sec starting index read\nmysql tables in use 1, locked 1\nLOCK WAIT 3 lock struct(s), heap size 360, 2 row lock(s)\nMySQL thread id 5537930, OS thread handle 0x7fa0d1c6d700, query id 39824554 localhost _root statistics\nselect * from deadlock where id=2 for update\n*** (1) WAITING FOR THIS LOCK TO BE GRANTED:\nRECORD LOCKS space id 2256 page no 3 n bits 72 index `PRIMARY` of table `db1`.`deadlock` trx id 1536028 lock_mode X locks rec but not gap waiting\nRecord lock, heap no 3 PHYSICAL RECORD: n_fields 5; compact format; info bits 0\n 0: len 4; hex 80000002; asc ;;\n 1: len 6; hex 00000017700d; asc p ;;\n 2: len 7; hex e5000001e20110; asc ;;\n 3: len 4; hex 80000016; asc ;;\n 4: len 4; hex 800000de; asc ;;\n\n*** (2) TRANSACTION:\nTRANSACTION 1536052, ACTIVE 17 sec starting index read\nmysql tables in use 1, locked 1\n3 lock struct(s), heap size 360, 2 row lock(s)\nMySQL thread id 5538800, OS thread handle 0x7fa0d07a5700, query id 39824639 localhost _root statistics\nselect * from deadlock where id=1 for update\n*** (2) HOLDS THE LOCK(S):\nRECORD LOCKS space id 2256 page no 3 n bits 72 index `PRIMARY` of table `db1`.`deadlock` trx id 1536052 lock_mode X locks rec but not gap\nRecord lock, heap no 3 PHYSICAL RECORD: n_fields 5; compact format; info bits 0\n 0: len 4; hex 80000002; asc ;;\n 1: len 6; hex 00000017700d; asc p ;;\n 2: len 7; hex e5000001e20110; asc ;;\n 3: len 4; hex 80000016; asc ;;\n 4: len 4; hex 800000de; asc ;;\n\n*** (2) WAITING FOR THIS LOCK TO BE GRANTED:\nRECORD LOCKS space id 2256 page no 3 n bits 72 index `PRIMARY` of table `db1`.`deadlock` trx id 1536052 lock_mode X locks rec but not gap waiting\nRecord lock, heap no 2 PHYSICAL RECORD: n_fields 5; compact format; info bits 0\n 0: len 4; hex 80000001; asc ;;\n 1: len 6; hex 00000017700c; asc p ;;\n 2: len 7; hex e4000001e10110; asc ;;\n 3: len 4; hex 8000000b; asc ;;\n 4: len 4; hex 8000006f; asc o;;\n\n*** WE ROLL BACK TRANSACTION (2)\n------------"
}