show processlist [all]
Available since 1.0.0.
命令说明
获取当前所有连接的信息,如果指定all,表示同时显示正在sleep的连接信息. 通过json格式输出,重定向到文本中显示会更清晰
shell> redis-cli -p 8903 show processlist all > a
shell> cat a
[
{
"id": 767, # session id
"host": "127.0.0.1:50834",
"args": [
"set",
"a",
"b"
],
"authed": 1,
"dbid": 0,
"start_time": 1587451514479, # 命令开始的毫秒时间戳
"duration": 153550, # 执行的时间(毫秒)
"session_ref": 3,
"holdinglocks": [ # 持有锁信息
[
5, # 锁的store id
"a", # key级锁
"X" # 锁的类型
]
]
},
{
"id": 3303,
"host": "127.0.0.1:51056",
"args": [
"get",
"a"
],
"authed": 1,
"dbid": 0,
"start_time": 1587451643100,
"duration": 24929,
"session_ref": 3,
"waitlock": [ # 等待锁的信息
5,
"a",
"X"
]
},
{
"id": 3589,
"host": "127.0.0.1:51069",
"args": [
"show",
"processlist",
"all"
],
"authed": 1,
"dbid": 0,
"start_time": 1587451668029,
"duration": 0,
"session_ref": 3
}
]
命令返回
Examples
如上
show locks
命令说明
获取当前tendis进程上所有线程持有的锁信息,主要用来获取当前所有锁的状态 以及 归属于哪个线程, 用于排查死锁,重复上锁等问题
如果当前没有锁, 显示如下:
127.0.0.1:51002> show locks
(empty list or set)
当前线程中包含锁的时候显示锁列表如下:
127.0.0.1:51003> show locks
1) "running: {id:12037349 target:store_4 targetHash:12626945507335128354 LockMode:X LockRes:0 threadId:0x7fbc345f0700}"
2) "running: {id:12037353 target:store_8 targetHash:5894286778622387524 LockMode:X LockRes:0 threadId:0x7fbc345f0700}"
3) "running: {id:12037352 target:store_7 targetHash:14410881189481979652 LockMode:X LockRes:0 threadId:0x7fbc345f0700}"
4) "running: {id:12037348 target:store_3 targetHash:2921060641710983428 LockMode:X LockRes:0 threadId:0x7fbc345f0700}"
5) "pending: {id:12037356 target:store_3 targetHash:2921060641710983428 LockMode:IX LockRes:1 threadId:0x7fbc211cb700}"
6) "running: {id:12037345 target:store_0 targetHash:8597937682813753033 LockMode:X LockRes:0 threadId:0x7fbc345f0700}"
7) "pending: {id:12037355 target:store_0 targetHash:8597937682813753033 LockMode:IX LockRes:1 threadId:0x7fbc219cc700}"
8) "pending: {id:12037359 target:store_0 targetHash:8597937682813753033 LockMode:IS LockRes:1 threadId:0x7fbc0e3e0700}"
9) "running: {id:12037354 target:store_9 targetHash:227896731122534032 LockMode:X LockRes:0 threadId:0x7fbc345f0700}"
10) "running: {id:12037351 target:store_6 targetHash:875462629852764501 LockMode:X LockRes:0 threadId:0x7fbc345f0700}"
11) "running: {id:12037347 target:store_2 targetHash:11940324784125777240 LockMode:X LockRes:0 threadId:0x7fbc345f0700}"
12) "running: {id:12037350 target:store_5 targetHash:7939884790480503227 LockMode:X LockRes:0 threadId:0x7fbc345f0700}"
13) "pending: {id:12037358 target:store_5 targetHash:7939884790480503227 LockMode:IX LockRes:1 threadId:0x7fbc201c9700}"
14) "running: {id:12037346 target:store_1 targetHash:11400597207708767293 LockMode:X LockRes:0 threadId:0x7fbc345f0700}"
15) "pending: {id:12037357 target:store_1 targetHash:11400597207708767293 LockMode:IX LockRes:1 threadId:0x7fbc209ca700}"
running表示以及获取的锁,pending表示正在等待的锁
id:锁id
target: 上锁的对象,可能是store锁,chunk锁或者key锁
targetHash:上锁shard等信息做hash得到的值,一般不需要关注
lockMode: 锁的类型,有S锁,IS锁,X锁,IX锁
threadId: 当前锁是属于哪个线程ID, 主要这个不是pid, 而是pstack输出的进程堆栈信息中的ID
Examples
如上