数据库版本:

mysql> select @@version;
+------------+
| @@version |
+------------+
| 5.7.26-log |
+------------+

事务隔离级别:

mysql> show variables like '%iso%';
+-----------------------+----------------+
| Variable_name | Value |
+-----------------------+----------------+
| transaction_isolation | READ-COMMITTED |
| tx_isolation | READ-COMMITTED |
+-----------------------+----------------+

 

会话一:关闭自动提交,锁定表中一行数据

mysql> set autocommit=0;
Query OK, 0 rows affected (0.00 sec) mysql> select * from sbtest1 where id=1 lock in share mode;
+----+------+-------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------+------+-------+-------+-------+-------+-------+-------+--------+--------+------+------+------+
| id | k | c | pad | name | name2 | name5 | name6 | name7 | name8 | name9 | name10 | name11 | c1 | c2 | c3 |
+----+------+-------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------+------+-------+-------+-------+-------+-------+-------+--------+--------+------+------+------+
| 1 | 5015 | 68487932199-96439406143-93774651418-41631865787-96406072701-20604855487-25459966574-28203206787-41238978918-19503783441 | 22195207048-70116052123-74140395089-76317954521-98694025897 | aa | bb | a | a | a | a | a | a | a | NULL | NULL | 0 |
+----+------+-------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------+------+-------+-------+-------+-------+-------+-------+--------+--------+------+------+------+
1 row in set (0.00 sec)

会话二:对该表做DDL操作

mysql> set autocommit=0;
Query OK, 0 rows affected (0.00 sec)
mysql> alter table sbtest1 add cc1 int;

会话三:显示事务在等待数据字典锁,但在innodb的锁信息表中并未给出锁堵塞信息

mysql> show processlist;
+-------+-----------------+--------------------+---------------+---------+---------+---------------------------------+---------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-------+-----------------+--------------------+---------------+---------+---------+---------------------------------+---------------------------------+
| 1 | event_scheduler | localhost | NULL | Daemon | 1549348 | Waiting on empty queue | NULL |
| 39327 | root | 10.200.21.13:39600 | canal_manager | Sleep | 884 | | NULL |
| 39436 | root | localhost | sysbench_db | Query | 51 | Waiting for table metadata lock | alter table sbtest1 add cc1 int |
| 39465 | root | localhost | NULL | Query | 0 | starting | show processlist |
| 39506 | root | localhost | sysbench_db | Query | 6 | Waiting for table metadata lock | select * from sbtest1 |
| 39511 | root | localhost | sysbench_db | Sleep | 137 | | NULL |
+-------+-----------------+--------------------+---------------+---------+---------+---------------------------------+---------------------------------+
6 rows in set (0.00 sec)
mysql> select * from INNODB_TRX;
+-----------------+-----------+---------------------+-----------------------+------------------+------------+---------------------+-----------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+
| trx_id | trx_state | trx_started | trx_requested_lock_id | trx_wait_started | trx_weight | trx_mysql_thread_id | trx_query | trx_operation_state | trx_tables_in_use | trx_tables_locked | trx_lock_structs | trx_lock_memory_bytes | trx_rows_locked | trx_rows_modified | trx_concurrency_tickets | trx_isolation_level | trx_unique_checks | trx_foreign_key_checks | trx_last_foreign_key_error | trx_adaptive_hash_latched | trx_adaptive_hash_timeout | trx_is_read_only | trx_autocommit_non_locking |
+-----------------+-----------+---------------------+-----------------------+------------------+------------+---------------------+-----------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+
| 421422174436976 | RUNNING | 2019-11-15 09:38:10 | NULL | NULL | 2 | 39511 | NULL | NULL | 0 | 1 | 2 | 1136 | 1 | 0 | 0 | READ COMMITTED | 1 | 1 | NULL | 0 | 0 | 0 | 0 |
+-----------------+-----------+---------------------+-----------------------+------------------+------------+---------------------+-----------+---------------------+-------------------+-------------------+------------------+-----------------------+-----------------+-------------------+-------------------------+---------------------+-------------------+------------------------+----------------------------+---------------------------+---------------------------+------------------+----------------------------+
1 row in set (0.00 sec) mysql> select * from INNODB_locks;
Empty set, 1 warning (0.00 sec) mysql> select * from INNODB_LOCK_WAITS;
Empty set, 1 warning (0.00 sec)
mysql> show engine innodb status \G;
*************************** 1. row ***************************
Type: InnoDB
Name:
Status:
=====================================
2019-11-15 09:45:19 0x7f47c8d38700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 11 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 3581 srv_active, 0 srv_shutdown, 1542568 srv_idle
srv_master_thread log flush and writes: 1546144
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 30450
OS WAIT ARRAY INFO: signal count 19118
RW-shared spins 0, rounds 15075, OS waits 6862
RW-excl spins 0, rounds 433241, OS waits 12516
RW-sx spins 1169, rounds 35046, OS waits 873
Spin rounds per wait: 15075.00 RW-shared, 433241.00 RW-excl, 29.98 RW-sx
------------------------
LATEST DETECTED DEADLOCK
------------------------
2019-11-14 09:55:27 0x7f47c8a20700
*** (1) TRANSACTION:
TRANSACTION 8801, ACTIVE 1 sec starting index read
mysql tables in use 1, locked 1
LOCK WAIT 4 lock struct(s), heap size 1136, 3 row lock(s), undo log entries 2
MySQL thread id 16018, OS thread handle 139946286548736, query id 99910 10.138.61.12 root updating
DELETE FROM sbtest1 WHERE id=4999
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space     not gap waiting
Record lock, heap no 73 PHYSICAL RECORD: n_fields 6; compact format; info bits 0
0: len 4; hex 80001387; asc ;;
1: len 6; hex 00000000225b; asc "[;;
2: len 7; hex 2e000000201fdb; asc . ;;
3: len 4; hex 80001375; asc u;;
4: len 30; hex 36323536333834383835322d34313830333137393631382d383536313634; asc 62563848852-41803179618-856164; (total 120 bytes);
5: len 30; hex 33303032343434313836392d36363935353436363130382d323939353039; asc 30024441869-66955466108-299509; (total 60 bytes); *** (2) TRANSACTION:
TRANSACTION 8795, ACTIVE 1 sec starting index read, thread declared inside InnoDB 5000
mysql tables in use 1, locked 1
4 lock struct(s), heap size 1136, 3 row lock(s), undo log entries 2
MySQL thread id 16017, OS thread handle 139946285467392, query id 99920 10.138.61.12 root updating
DELETE FROM sbtest1 WHERE id=4979
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 57 page no 100 n bits 144 index PRIMARY of table `sysbench_db`.`sbtest1` trx id 8795 lock_mode X locks rec but not gap
Record lock, heap no 73 PHYSICAL RECORD: n_fields 6; compact format; info bits 0
0: len 4; hex 80001387; asc ;;
1: len 6; hex 00000000225b; asc "[;;
2: len 7; hex 2e000000201fdb; asc . ;;
3: len 4; hex 80001375; asc u;;
4: len 30; hex 36323536333834383835322d34313830333137393631382d383536313634; asc 62563848852-41803179618-856164; (total 120 bytes);
5: len 30; hex 33303032343434313836392d36363935353436363130382d323939353039; asc 30024441869-66955466108-299509; (total 60 bytes); *** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 57 page no 100 n bits 144 index PRIMARY of table `sysbench_db`.`sbtest1` trx id 8795 lock_mode X locks rec but not gap waiting
Record lock, heap no 53 PHYSICAL RECORD: n_fields 6; compact format; info bits 0
0: len 4; hex 80001373; asc s;;
1: len 6; hex 000000002261; asc "a;;
2: len 7; hex 310000001f2239; asc 1 "9;;
3: len 4; hex 800013aa; asc ;;
4: len 30; hex 31333735393532343036322d37383433393531343532342d383137393338; asc 13759524062-78439514524-817938; (total 120 bytes);
5: len 30; hex 34353737383233343435352d38303336313338353035392d383834323633; asc 45778234455-80361385059-884263; (total 60 bytes); *** WE ROLL BACK TRANSACTION (2)
------------
TRANSACTIONS
------------
Trx id counter 2258851
Purge done for trx's n:o < 2258850 undo n:o < 0 state: running but idle
History list length 49
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421422174438800, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421422174437888, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421422174436064, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
---TRANSACTION 421422174435152, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (read thread)
I/O thread 7 state: waiting for completed aio requests (read thread)
I/O thread 8 state: waiting for completed aio requests (read thread)
I/O thread 9 state: waiting for completed aio requests (read thread)
I/O thread 10 state: waiting for completed aio requests (write thread)
I/O thread 11 state: waiting for completed aio requests (write thread)
I/O thread 12 state: waiting for completed aio requests (write thread)
I/O thread 13 state: waiting for completed aio requests (write thread)
I/O thread 14 state: waiting for completed aio requests (write thread)
I/O thread 15 state: waiting for completed aio requests (write thread)
I/O thread 16 state: waiting for completed aio requests (write thread)
I/O thread 17 state: waiting for completed aio requests (write thread)
Pending normal aio reads: [0, 0, 0, 0, 0, 0, 0, 0] , aio writes: [0, 0, 0, 0, 0, 0, 0, 0] ,
ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 0
613084 OS file reads, 1249482 OS file writes, 643052 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 126, seg size 128, 20513 merges
merged operations:
insert 124338, delete mark 486, delete 0
discarded operations:
insert 35606, delete mark 359, delete 0
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 1 buffer(s)
Hash table size 34679, node heap has 231 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 1625718660
Log flushed up to 1625718660
Pages flushed up to 1625718660
Last checkpoint at 1625718651
0 pending log flushes, 0 pending chkp writes
585541 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total large memory allocated 137428992
Dictionary memory allocated 264434
Buffer pool size 8192
Free buffers 4096
Database pages 3858
Old database pages 1404
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 51385, not young 13979456
0.00 youngs/s, 0.00 non-youngs/s
Pages read 612973, created 365347, written 614329
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
No buffer pool page gets since the last printout
Pages read ahead 0.00/s, evicted without access 0.00/s, Random read ahead 0.00/s
LRU len: 3858, unzip_LRU len: 0
I/O sum[0]:cur[0], unzip sum[0]:cur[0]
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Process ID=2589, Main thread ID=139946660714240, state: sleeping
Number of rows inserted 8673974, updated 7522, deleted 3147, read 45773008
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================ 1 row in set (0.09 sec) ERROR:
No query specified

  

  

MySQL5.7 慢查询+DDL操作堵塞查询的更多相关文章

  1. MySQL 查询in操作,查询结果按in集合顺序显示

    MySQL 查询in操作,查询结果按in集合顺序显示   select * from test where id in(3,1,5) order by find_in_set(id,'3,1,5'); ...

  2. MySQL查询in操作 查询结果按in集合顺序显示(转)

    MySQL 查询in操作,查询结果按in集合顺序显示的实现代码,需要的朋友可以参考下. MySQL 查询in操作,查询结果按in集合顺序显示 复制代码代码如下: select * from test ...

  3. MySQL查询in操作 查询结果按in集合顺序显示_Mysql_脚本之家

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...

  4. oracle-2-sql数据操作和查询

    主要内容: >oracle 数据类型 >sql建表和约束 >sql对数九的增删改 >sql查询 >oracle伪例 1.oracle的数据类型 oracle数据库的核心是 ...

  5. Oracle 之——子查询 DDL DML 集合 及其他数据对象

    Oracle 学习笔记(二) 知识概要: 1.子查询 2.集合操作 3.DML语句操作 4.其他数据库对象 1.子查询 查询工资比SCOTT高的员工信息 1  select * 2  from emp ...

  6. MySQL数据操作与查询笔记 • 【目录】

    持续更新中- 我的大学笔记>>> 章节 内容 第1章 MySQL数据操作与查询笔记 • [第1章 MySQL数据库基础] 第2章 MySQL数据操作与查询笔记 • [第2章 表结构管 ...

  7. mysql表查询、多表查询(增强查询的使用)子查询、合并查询,外连接,mysql5种约束,自增长

    一.查询加强 1.在mysql中,日期类型可以直接比较,需要注意格式 2.%:表示0到多个字符, _:表示单个字符 exp:显示第二个字符为大写O的所有员工的姓名和工资 select  name fr ...

  8. Linq to SQL 语法查询(链接查询,子查询 & in操作 & join,分组统计等)

    Linq to SQL 语法查询(链接查询,子查询 & in操作 & join,分组统计等) 子查询 描述:查询订单数超过5的顾客信息 查询句法: var 子查询 = from c i ...

  9. MongoDB常用操作一查询find方法db.collection_name.find()

    来:http://blog.csdn.net/wangli61289/article/details/40623097 https://docs.mongodb.org/manual/referenc ...

随机推荐

  1. 对includes的研究

    1.includes() 方法用来判断一个数组是否包含一个指定的值,如果是返回 true,否则false. 2.let site = ['runoob', 'google', 'taobao']; s ...

  2. vue中的:is

    is string | Object (组件的选项对象) <div id="app"> <span>这是:is的案例</span> <co ...

  3. springboot日期转换器

    注:该功能并非springboot特有的功能,springmvc同样具有         一.使用方法     创建一个DateConverter类实现Converter接口 注:importorg. ...

  4. handy源码阅读(四):Channel类

    通道,封装了可以进行epoll的一个fd. struct Channel: private noncopyable { Channel(EventBase* base, int fd, int eve ...

  5. Mysql中主键与索引

    摘自: https://www.cnblogs.com/wicub/p/5898286.html 一.什么是索引?索引用来快速地寻找那些具有特定值的记录,所有MySQL索引都以B-树的形式保存.如果没 ...

  6. cdn for js library

    https://cdnjs.com/libraries/jquery https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js htt ...

  7. ORACLE表空间offline谈起,表空间备份恢复

    从ORACLE表空间offline谈起,表空间备份恢复将表空间置为offline,可能的原因包括维护.备份恢复等目的:表空间处于offline状态,那么Oracle不会允许任何对该表空间中对象的SQL ...

  8. 十二、python字符串方法汇总

    '''1. index():检测字符串str1中是否包含字符串str2 语法:str1.index(str2,beg,end) str:指定检索的字符串:beg开始的索引,默认为0:end结束的索引, ...

  9. Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包

    Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包. 18 (flaskApi) [root@67 flaskDemo]# yum -y install n ...

  10. 阶段1 语言基础+高级_1-3-Java语言高级_1-常用API_1_第5节 String类_9_练习:按指定格式拼接字符

    数组再加一个值