获取MySQL实例死锁信息
更新时间:2024-11-15
接口描述
获取MySQL实例 最近一次死锁信息
权限说明
鉴权认证机制的详细内容请参见鉴权认证。
请求结构
JSON
1GET /v{version}/diagnosis/mysql/deadlock/latest?appId=appId&nodeId=nodeId HTTP/1.1
2Host: dbsc.bj.baidubce.com
3Authorization: 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-是 |
请求示例
JSON
1GET /v1/diagnosis/mysql/deadlock/latest?appId=rds-0mxm0cTI&nodeId=rds-0mxm0cTI HTTP/1.1
2Host: dbsc.bj.baidubce.com
3Content-Type: application/json
4Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2023-07-11T11:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
响应示例
JSON
1HTTP/1.1 200 OK
2Content-Type: application/json;charset=UTF-8
3x-bce-request-id: d8752367-38e8-45e4-b4c7-e53be3137ce5
4{
5 "transactionLocks": [
6 {
7 "trxSeq": 1,
8 "trxId": "1536028",
9 "trxTime": "2024-10-18T02:54:12Z",
10 "duration": 86,
11 "ip": "",
12 "hostname": "localhost",
13 "threadID": 5537930,
14 "user": "_root",
15 "query": "select * from deadlock where id=2 for update",
16 "victim": 0,
17 "locks": [
18 {
19 "lockType": "RECORD",
20 "lockMode": "X",
21 "database": "db1",
22 "table": "deadlock",
23 "index": "PRIMARY",
24 "recordLockType": "LOCK_REC_NOT_GAP",
25 "spaceId": 2256,
26 "pageNo": 3,
27 "heapNo": 3,
28 "waitHold": "WAIT",
29 "isPrediction": false
30 },
31 {
32 "lockType": "RECORD",
33 "lockMode": "X",
34 "database": "db1",
35 "table": "deadlock",
36 "index": "PRIMARY",
37 "recordLockType": "LOCK_REC_NOT_GAP",
38 "spaceId": 2256,
39 "pageNo": 3,
40 "heapNo": 2,
41 "waitHold": "HOLD",
42 "isPrediction": true
43 }
44 ]
45 },
46 {
47 "trxSeq": 2,
48 "trxId": "1536052",
49 "trxTime": "2024-10-18T02:55:21Z",
50 "duration": 17,
51 "ip": "",
52 "hostname": "localhost",
53 "threadID": 5538800,
54 "user": "_root",
55 "query": "select * from deadlock where id=1 for update",
56 "victim": 1,
57 "locks": [
58 {
59 "lockType": "RECORD",
60 "lockMode": "X",
61 "database": "db1",
62 "table": "deadlock",
63 "index": "PRIMARY",
64 "recordLockType": "LOCK_REC_NOT_GAP",
65 "spaceId": 2256,
66 "pageNo": 3,
67 "heapNo": 3,
68 "waitHold": "HOLD",
69 "isPrediction": false
70 },
71 {
72 "lockType": "RECORD",
73 "lockMode": "X",
74 "database": "db1",
75 "table": "deadlock",
76 "index": "PRIMARY",
77 "recordLockType": "LOCK_REC_NOT_GAP",
78 "spaceId": 2256,
79 "pageNo": 3,
80 "heapNo": 2,
81 "waitHold": "WAIT",
82 "isPrediction": false
83 }
84 ]
85 }
86 ],
87 "metaInfo": {
88 "timestamp": "2024-10-18T02:55:38Z",
89 "deadLockId": "7fa0d07a5700"
90 },
91 "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------------"
92}