MySQL5.7 慢查询+DDL操作堵塞查询
数据库版本:
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操作堵塞查询的更多相关文章
- MySQL 查询in操作,查询结果按in集合顺序显示
MySQL 查询in操作,查询结果按in集合顺序显示 select * from test where id in(3,1,5) order by find_in_set(id,'3,1,5'); ...
- MySQL查询in操作 查询结果按in集合顺序显示(转)
MySQL 查询in操作,查询结果按in集合顺序显示的实现代码,需要的朋友可以参考下. MySQL 查询in操作,查询结果按in集合顺序显示 复制代码代码如下: select * from test ...
- MySQL查询in操作 查询结果按in集合顺序显示_Mysql_脚本之家
body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...
- oracle-2-sql数据操作和查询
主要内容: >oracle 数据类型 >sql建表和约束 >sql对数九的增删改 >sql查询 >oracle伪例 1.oracle的数据类型 oracle数据库的核心是 ...
- Oracle 之——子查询 DDL DML 集合 及其他数据对象
Oracle 学习笔记(二) 知识概要: 1.子查询 2.集合操作 3.DML语句操作 4.其他数据库对象 1.子查询 查询工资比SCOTT高的员工信息 1 select * 2 from emp ...
- MySQL数据操作与查询笔记 • 【目录】
持续更新中- 我的大学笔记>>> 章节 内容 第1章 MySQL数据操作与查询笔记 • [第1章 MySQL数据库基础] 第2章 MySQL数据操作与查询笔记 • [第2章 表结构管 ...
- mysql表查询、多表查询(增强查询的使用)子查询、合并查询,外连接,mysql5种约束,自增长
一.查询加强 1.在mysql中,日期类型可以直接比较,需要注意格式 2.%:表示0到多个字符, _:表示单个字符 exp:显示第二个字符为大写O的所有员工的姓名和工资 select name fr ...
- Linq to SQL 语法查询(链接查询,子查询 & in操作 & join,分组统计等)
Linq to SQL 语法查询(链接查询,子查询 & in操作 & join,分组统计等) 子查询 描述:查询订单数超过5的顾客信息 查询句法: var 子查询 = from c i ...
- MongoDB常用操作一查询find方法db.collection_name.find()
来:http://blog.csdn.net/wangli61289/article/details/40623097 https://docs.mongodb.org/manual/referenc ...
随机推荐
- 【leetcode】838. Push Dominoes
题目如下: 解题思路:本题题目中有一点要求很关键,“we will consider that a falling domino expends no additional force to a fa ...
- C文件 CMakeList.txt编译器配置错误的问题 error:invalid conversion from 'int' to 'LAYER_TYPE' [-fpermissive]....
在编译C工程时,遇到了如下错误: 一般看到类型错误,主要考虑是不是编译器错了. 以下引用:https://www.cnblogs.com/liushui-sky/p/7729838.html 后缀为. ...
- RSA和AES工具类
AESUtil import com.xxx.common.BssException; import com.xxx.common.constants.CommonConstants; import ...
- Javascript获取页面元素相对和绝对位置
制作网页的过程中,你有时候需要知道某个元素在网页上的确切位置. 下面的教程总结了Javascript在网页定位方面的相关知识. 一.网页的大小和浏览器窗口的大小 首先,要明确两个基本概念. 一张网页的 ...
- JS中的执行机制(setTimeout、setInterval、promise、宏任务、微任务)
1.执行机制 JS 是单线程的,处理 JS 任务(程序)只能一个一个顺序执行,所以 JS 中就把任务分为了同步任务和异步任务.同步的进入主线程先执行,异步的进入Event Table并注册函数,当指定 ...
- BZOJ 2427: [HAOI2010]软件安装 tarjan + 树形背包
Description 现在我们的手头有N个软件,对于一个软件i,它要占用Wi的磁盘空间,它的价值为Vi.我们希望从中选择一些软件安装到一台磁盘容量为M计算机上,使得这些软件的价值尽可能大(即Vi的和 ...
- Logstash介绍及Input插件介绍
一.Logstash简介 Logstash是一个开源数据收集引擎,具有实时管道功能.Logstash可以动态地将来自不同数据源的数据统一起来,并将数据标准化到你所选择的目的地. Logstash管 ...
- Leetcode 6. ZigZag Conversion(找规律,水题)
6. ZigZag Conversion Medium The string "PAYPALISHIRING" is written in a zigzag pattern on ...
- Internet History, Technology, and Security(week2)——History: The First Internet - NSFNet
前言: 上周学习了<电子计算机的曙光>,对战时及战后的计算机的历史发展有了更丰富的了解,今天继续coursera的课程,感觉已经有点适应了课程的节奏(除了经常有些奇奇怪怪的词汇看都看不懂@ ...
- PHP快速教程
1.本文主要针对有C语言(或其他编程语言)基础的人快速学习PHP的,所以不会对一些基础知识作过多解释,比如“=”是赋值不是等于. 2.本文适合已学过一门编程语言,想要快速入门PHP的人. 3.基本上看 ...