关闭

锁排查--实例

357人阅读 评论(0) 收藏 举报
分类:
mysql>  show processlist;
+----+------+-----------+------+---------+------+-------+------------------+
| Id | User | Host      | db   | Command | Time | State | Info             |
+----+------+-----------+------+---------+------+-------+------------------+
|  1 | root | localhost | NULL | Query   |    0 | init  | show processlist |
|  2 | test | localhost | NULL | Sleep   |   43 |       | NULL             |
+----+------+-----------+------+---------+------+-------+------------------+
2 rows in set (0.00 sec)

mysql> 



SESSION 1:

3 | test | localhost | test | Sleep   |   25 |       | NULL            

mysql> create table t7(id int);
Query OK, 0 rows affected (0.33 sec)

mysql>  lock table  t7 read;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values(1);
ERROR 1100 (HY000): Table 't1' was not locked with LOCK TABLES


SESSION 2:

|  4 | test | localhost | test | Sleep   |   10 |       | NULL   

mysql> insert into t7 values(1);  ----HANG



清空/var/log/mysql/mysqld.log ,执行mysqladmin -uroot -p1234567 -h127.0.0.1 debug



Thread database.table_name          Locked/Waiting        Lock_type

3       test.t7                     Locked - read         Read lock without concurrent inserts   ---持有读锁
4       test.t7                     Waiting - write       Concurrent insert lock                 ---被堵塞

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1390768次
    • 积分:41648
    • 等级:
    • 排名:第93名
    • 原创:2896篇
    • 转载:14篇
    • 译文:0篇
    • 评论:54条
    文章分类
    最新评论