数据库版本:

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. NOIP模拟赛(by hzwer) T2 小奇的序列

    [题目背景] 小奇总是在数学课上思考奇怪的问题. [问题描述] 给定一个长度为 n 的数列,以及 m 次询问,每次给出三个数 l,r 和 P, 询问 (a[l'] + a[l'+1] + ... + ...

  2. php list()函数 语法

    php list()函数 语法 作用:用于在一次操作中给一组变量赋值.博智达 语法:list(var1,var2...) 参数: 参数 描述 var1 必需.第一个需要赋值的变量. var2,... ...

  3. [517]Kite 题解

    前言 今天又是爆零的一天. 被同学坑了,还以为四边形的点是按任意序给定的,然后打了一个特别复杂的矩形判断QAQ. 题意简述 按顺序给定一个四边形,求有多少个点在这个四边形的对称轴上. 题解 分情况讨论 ...

  4. PC端无论页面有没有完全撑开把footer保持在最底部(不用定位)

    最近在写项目,有的页面没有占到一屏,然后footer也就是底部就靠上了,这样很影响美观,于是在网上找了找,下面是我的成果 解决该问题的最好方法是采用CSS3提供的一种先进布局模型 :flexbox,可 ...

  5. Conturbatio

    Conturbatio Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  6. CG-CTF | 上传绕过

    最近一直在做算法题,头都要大了,今天悄咪咪来一个web换换脑子,一发flag敲开♥[虽然知道这是个水题ε=ε=ε=┏(゜ロ゜;)┛]

  7. [CSP-S模拟测试]:礼物(数学)

    题目传送门(内部题80) 输入格式 第一行输入一个正整数$n$. 第二行到第$n+1$行每行两个正整数$a_i$和$b_i$表示第$i$个礼物中包含$a_i$个红宝石和$b_i$个绿宝石. 输出格式 ...

  8. 2019年CCPC网络赛 HDU 6703 array【权值线段树】

    题目大意:给出一个n个元素的数组A,A中所有元素都是不重复的[1,n].有两种操作:1.将pos位置的元素+1e72.查询不属于[1,r]中的最小的>=k的值.强制在线. 题解因为数组中的值唯一 ...

  9. React-Native 之 GD (十三)数据持久化(realm) 及 公共Cell

    1.数据持久化 数据持久化是移动端的一个重要部分,刚发现 Realm 原来已经支持 React-Native 了 步骤一: 引入 realm $ npm install realm --save 步骤 ...

  10. 第三方框架:EventBus

    1 研发背景 案例:我们在主页点收藏按钮,未登录状态,跳登录界面,在登录界面跳注册页面,注册成功,关闭注册页面,关闭登录页面,回到主页,刷新item列表和登录状态. 我们一般会用到发送广播和接收广播来 ...