zoukankan      html  css  js  c++  java
  • 结论: blocking_query 是当前堵塞其他会话正在运行的SQL.而不是原始堵塞SQL

    查看当前session线程号
    mysql>  select connection_id(); 
    +-----------------+
    | connection_id() |
    +-----------------+
    |              28 |
    +-----------------+
    1 row in set (0.02 sec)
    
    
    
    Session 1:
    
    Vsftp:/root#  mysql -uroot -p1234567 -e " show processlist"
    Warning: Using a password on the command line interface can be insecure.
    +----+------+-----------+------+---------+------+-------+------------------+
    | Id | User | Host      | db   | Command | Time | State | Info             |
    +----+------+-----------+------+---------+------+-------+------------------+
    | 17 | root | localhost | zjzc | Sleep   |    0 |       | NULL             |
    
    
    mysql 进程1737
    root      1737   979  0 13:02 pts/1    00:00:00 mysql -uroot -px xxxxx
    
    
    mysql> start transaction;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> delete from test where id=1;
    Query OK, 1 row affected (0.00 sec)
    
    
    Session 2:
    
    
    | 28 | root | localhost | zjzc | Sleep   |    2 |       | NULL  
    
    
    查看堵塞:
     mysql[192.168.11.187]   blocking_thread[17] blocking_query[]  blocking waiting_thread[28]'s delete from test where id=1
    
    mysql> SELECT 
        ->     r.trx_id waiting_trx_id,
        ->     r.trx_mysql_thread_id waiting_thread,
        ->     r.trx_query waiting_query,
        ->     b.trx_id blocking_trx_id,
        ->     b.trx_mysql_thread_id blocking_thread,
        ->     b.trx_query blocking_query
        -> FROM
        ->     information_schema.innodb_lock_waits w
        ->         INNER JOIN
        ->     information_schema.innodb_trx b ON b.trx_id = w.blocking_trx_id
        ->         INNER JOIN
        ->     information_schema.innodb_trx r ON r.trx_id = w.requesting_trx_id;
    +----------------+----------------+-----------------------------+-----------------+-----------------+----------------+
    | waiting_trx_id | waiting_thread | waiting_query               | blocking_trx_id | blocking_thread | blocking_query |
    +----------------+----------------+-----------------------------+-----------------+-----------------+----------------+
    | 112076626      |             28 | delete from test where id=1 | 112076625       |              17 | NULL           |
    +----------------+----------------+-----------------------------+-----------------+-----------------+----------------+
    1 row in set (0.00 sec)
    
    
    
    Session 1:运行
    mysql> select * from ClientActionTrack20151125
    
     mysql[192.168.11.187]   blocking_thread[17] blocking_query[select * from ClientActionTrack20151125]  blocking waiting_thread[28]'s delete from test where id=1
    
    mysql> SELECT      r.trx_id waiting_trx_id,     r.trx_mysql_thread_id waiting_thread,     r.trx_query waiting_query,     b.trx_id blocking_trx_id,     b.trx_mysql_thread_id blocking_thread,     b.trx_query blocking_query FROM     information_schema.innodb_lock_waits w         INNER JOIN     information_schema.innodb_trx b ON b.trx_id = w.blocking_trx_id         INNER JOIN     information_schema.innodb_trx r ON r.trx_id = w.requesting_trx_id;
    +----------------+----------------+-----------------------------+-----------------+-----------------+-----------------------------------------+
    | waiting_trx_id | waiting_thread | waiting_query               | blocking_trx_id | blocking_thread | blocking_query                          |
    +----------------+----------------+-----------------------------+-----------------+-----------------+-----------------------------------------+
    | 112076626      |             28 | delete from test where id=1 | 112076625       |              17 | select * from ClientActionTrack20151125 |
    +----------------+----------------+-----------------------------+-----------------+-----------------+-----------------------------------------+
    1 row in set (0.39 sec)
    
    
    
    结论: blocking_query 是当前堵塞其他会话正在运行的SQL.而不是原始堵塞SQL

  • 相关阅读:
    MVC4中Ajax.BeginForm OnSuccess 不执行以及控制器返回JsonResult 提示下载的原因
    string.Equals 比较2个字符串是否相同忽略大小写
    [转载]mvc使用JsonResult返回Json数据
    [转载]深入理解ASP.NET MVC之ActionResult
    [转载]自定义ASP.NET MVC Html辅助方法 TagBuilder
    [转载]AOP面向方面编程
    [转载]ASP.NET MVC 3的分部视图
    适配 iOS尺寸
    IOS Bug分析
    苹果一些乱七八糟流程整理
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349999.html
Copyright © 2011-2022 走看看