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

  • 相关阅读:
    Android开发笔记——WebView
    字符串_最小表示法求循环串的最小序列(HDU_4162)
    STL_map简单应用(HDU_1075)
    DP_最大子序列和(HDU_1003)
    STL map 使用方法(转)
    数学_线性筛法建立素数表(HDU_1262)
    學習筆記 ADO數據庫訪問技術
    C#多线程学习
    Java容器
    选取单元格的基本语句
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349999.html
Copyright © 2011-2022 走看看