一文详细讲解如何查看mysql里面的锁

一文详细讲解如何查看mysql里面的锁

Trx id counter 3957 #下一个待分配的事务id

Purge done for trx’s n:o < 3930 undo n:o < 0 state: running but idle

History list length 0

LIST OF TRANSACTIONS FOR EACH SESSION: #各个事务信息

—TRANSACTION 421799341399664, not started

0 lock struct(s), heap size 1136, 0 row lock(s)

—TRANSACTION 421799341400576, not started

0 lock struct(s), heap size 1136, 0 row lock(s)

—TRANSACTION 421799341403312, not started

0 lock struct(s), heap size 1136, 0 row lock(s)

—TRANSACTION 421799341398752, not started

0 lock struct(s), heap size 1136, 0 row lock(s)

—TRANSACTION 3956, ACTIVE 25 sec #事务id为3956的事务,活跃时间25秒

3 lock struct(s), heap size 1136, 27 row lock(s)

MySQL thread id 991, OS thread handle 140323910289152, query id 10636 localhost root

TABLE LOCK table sakila.actor trx id 3956 lock mode IX #事务id为3956的事务,对sakila.actor加了表级别意向独占锁 IX

RECORD LOCKS space id 45 page no 5 n bits 272 index idx_actor_first of table sakila.actor trx id 3956 lock_mode X

Record lock, heap no 2 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 #idx_actor_first 是二级索引,lock_mode X Record lock 表示X型的next_key 锁

0: len 4; hex 4144414d; asc ADAM;;

1: len 2; hex 0047; asc G;;

Record lock, heap no 3 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 4; hex 4144414d; asc ADAM;;

1: len 2; hex 0084; asc ;;

Record lock, heap no 4 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 2; hex 414c; asc AL;;

1: len 2; hex 00a5; asc ;;

Record lock, heap no 5 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 4; hex 414c414e; asc ALAN;;

1: len 2; hex 00ad; asc ;;

Record lock, heap no 6 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 6; hex 414c42455254; asc ALBERT;;

1: len 2; hex 007d; asc };;

Record lock, heap no 7 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 6; hex 414c42455254; asc ALBERT;;

1: len 2; hex 0092; asc ;;

Record lock, heap no 8 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 4; hex 414c4543; asc ALEC;;

1: len 2; hex 001d; asc ;;

Record lock, heap no 9 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 6; hex 414e47454c41; asc ANGELA;;

1: len 2; hex 0041; asc A;;

Record lock, heap no 10 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 6; hex 414e47454c41; asc ANGELA;;

1: len 2; hex 0090; asc ;;

Record lock, heap no 11 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 8; hex 414e47454c494e41; asc ANGELINA;;

1: len 2; hex 004c; asc L;;

Record lock, heap no 12 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 4; hex 414e4e45; asc ANNE;;

1: len 2; hex 0031; asc 1;;

Record lock, heap no 13 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 6; hex 415544524559; asc AUDREY;;

1: len 2; hex 0022; asc ";;

Record lock, heap no 14 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 6; hex 415544524559; asc AUDREY;;

1: len 2; hex 00be; asc ;;

Record lock, heap no 15 PHYSICAL RECORD: n_fields 2; compact format; info bits 0

0: len 4; hex 42454c41; asc BELA;;

1: len 2; hex 00c4; asc ;;

RECORD LOCKS space id 45 page no 3 n bits 272 index PRIMARY of table sakila.actor trx id 3956 lock_mode X locks rec but not gap

Record lock, heap no 30 PHYSICAL RECORD: n_fields 6; compact format; info bits 0 # trx id 3956 聚簇索引PRIMARY ,lock_mode X locks rec but not gap Record lock 表示X型记录锁

0: len 2; hex 001d; asc ;;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b0228; asc + (;;

3: len 4; hex 414c4543; asc ALEC;;

4: len 5; hex 5741594e45; asc WAYNE;;

5: len 4; hex 43f23ed9; asc C > ;;

Record lock, heap no 35 PHYSICAL RECORD: n_fields 6; compact format; info bits 0

0: len 2; hex 0022; asc ";;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b025a; asc + Z;;

3: len 6; hex 415544524559; asc AUDREY;;

4: len 7; hex 4f4c4956494552; asc OLIVIER;;

5: len 4; hex 43f23ed9; asc C > ;;

Record lock, heap no 50 PHYSICAL RECORD: n_fields 6; compact format; info bits 0

0: len 2; hex 0031; asc 1;;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b02f0; asc + ;;

3: len 4; hex 414e4e45; asc ANNE;;

4: len 6; hex 43524f4e594e; asc CRONYN;;

5: len 4; hex 43f23ed9; asc C > ;;

Record lock, heap no 66 PHYSICAL RECORD: n_fields 6; compact format; info bits 0

0: len 2; hex 0041; asc A;;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b0390; asc + ;;

3: len 6; hex 414e47454c41; asc ANGELA;;

4: len 6; hex 485544534f4e; asc HUDSON;;

5: len 4; hex 43f23ed9; asc C > ;;

Record lock, heap no 72 PHYSICAL RECORD: n_fields 6; compact format; info bits 0

0: len 2; hex 0047; asc G;;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b03cc; asc + ;;

3: len 4; hex 4144414d; asc ADAM;;

4: len 5; hex 4752414e54; asc GRANT;;

5: len 4; hex 43f23ed9; asc C > ;;

Record lock, heap no 77 PHYSICAL RECORD: n_fields 6; compact format; info bits 0

0: len 2; hex 004c; asc L;;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b03fe; asc + ;;

3: len 8; hex 414e47454c494e41; asc ANGELINA;;

4: len 7; hex 41535441495245; asc ASTAIRE;;

5: len 4; hex 43f23ed9; asc C > ;;

Record lock, heap no 126 PHYSICAL RECORD: n_fields 6; compact format; info bits 0

0: len 2; hex 007d; asc };;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b05e8; asc + ;;

3: len 6; hex 414c42455254; asc ALBERT;;

4: len 5; hex 4e4f4c5445; asc NOLTE;;

5: len 4; hex 43f23ed9; asc C > ;;

Record lock, heap no 133 PHYSICAL RECORD: n_fields 6; compact format; info bits 0

0: len 2; hex 0084; asc ;;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b0631; asc + 1;;

3: len 4; hex 4144414d; asc ADAM;;

4: len 6; hex 484f50504552; asc HOPPER;;

5: len 4; hex 43f23ed9; asc C > ;;

Record lock, heap no 145 PHYSICAL RECORD: n_fields 6; compact format; info bits 0

0: len 2; hex 0090; asc ;;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b06b5; asc + ;;

3: len 6; hex 414e47454c41; asc ANGELA;;

4: len 11; hex 57495448455253504f4f4e; asc WITHERSPOON;;

5: len 4; hex 43f23ed9; asc C > ;;

Record lock, heap no 147 PHYSICAL RECORD: n_fields 6; compact format; info bits 0

0: len 2; hex 0092; asc ;;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b06cb; asc + ;;

3: len 6; hex 414c42455254; asc ALBERT;;

4: len 9; hex 4a4f48414e53534f4e; asc JOHANSSON;;

5: len 4; hex 43f23ed9; asc C > ;;

Record lock, heap no 166 PHYSICAL RECORD: n_fields 6; compact format; info bits 0

0: len 2; hex 00a5; asc ;;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b079c; asc + ;;

3: len 2; hex 414c; asc AL;;

4: len 7; hex 4741524c414e44; asc GARLAND;;

5: len 4; hex 43f23ed9; asc C > ;;

Record lock, heap no 174 PHYSICAL RECORD: n_fields 6; compact format; info bits 0

0: len 2; hex 00ad; asc ;;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b07f4; asc + ;;

3: len 4; hex 414c414e; asc ALAN;;

4: len 8; hex 4452455946555353; asc DREYFUSS;;

5: len 4; hex 43f23ed9; asc C > ;;

Record lock, heap no 191 PHYSICAL RECORD: n_fields 6; compact format; info bits 0

0: len 2; hex 00be; asc ;;

1: len 6; hex 000000000ef8; asc ;;

2: len 7; hex cf0000032b08af; asc + ;;

3: len 6; hex 415544524559; asc AUDREY;;

4: len 6; hex 4241494c4559; asc BAILEY;;

5: len 4; hex 43f23ed9; asc C > ;;

从上我们可以看到此事务在表actor上,加上了

mysql> select * from actor where first_name >’A' and first_name <'B' for update;

+———-+————+————-+———————+

| actor_id | first_name | last_name | last_update |

+———-+————+————-+———————+

| 71 | ADAM | GRANT | 2006-02-15 04:34:33 |

| 132 | ADAM | HOPPER | 2006-02-15 04:34:33 |

| 165 | AL | GARLAND | 2006-02-15 04:34:33 |

| 173 | ALAN | DREYFUSS | 2006-02-15 04:34:33 |

| 125 | ALBERT | NOLTE | 2006-02-15 04:34:33 |

| 146 | ALBERT | JOHANSSON | 2006-02-15 04:34:33 |

| 29 | ALEC | WAYNE | 2006-02-15 04:34:33 |

| 65 | ANGELA | HUDSON | 2006-02-15 04:34:33 |

| 144 | ANGELA | WITHERSPOON | 2006-02-15 04:34:33 |

| 76 | ANGELINA | ASTAIRE | 2006-02-15 04:34:33 |

| 49 | ANNE | CRONYN | 2006-02-15 04:34:33 |

| 34 | AUDREY | OLIVIER | 2006-02-15 04:34:33 |

| 190 | AUDREY | BAILEY | 2006-02-15 04:34:33 |

+———-+————+————-+———————+

13 rows in set (0.00 sec)| actor |

相关推荐

怀孕下载什么软件好
365bet365网址

怀孕下载什么软件好

📅 12-20 👁️ 9019
K95 RGB PLATINUM XT Mechanical Gaming Keyboard
英国最大赌博365网站

K95 RGB PLATINUM XT Mechanical Gaming Keyboard

📅 01-13 👁️ 2589
“我为什么要学英语?”这是我见过最真实的回答!
英国最大赌博365网站

“我为什么要学英语?”这是我见过最真实的回答!

📅 07-08 👁️ 8945