博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL • 特性分析 • 到底是谁执行了FTWL
阅读量:5732 次
发布时间:2019-06-18

本文共 3752 字,大约阅读时间需要 12 分钟。

[test]> flush tables with read lock;Query OK, 0 rows affected (0.06 sec)[test]> show full processlist\G*************************** 1. row ***************************  Id: 10  User: root  Host: localhost  db: test Command: Query Time: 0 State: init Info: show full processlistProgress: 0.000*************************** 2. row ***************************  Id: 11  User: root  Host: localhost  db: test Command: Query Time: 743 State: Waiting for global read lock Info: delete from t0Progress: 0.0002 rows in set (0.00 sec)[test]> select * from information_schema.processlist\G*************************** 1. row ***************************  ID: 11  USER: root  HOST: localhost  DB: test  COMMAND: Query  TIME: 954  STATE: Waiting for global read lock  INFO: delete from t0  TIME_MS: 954627.587  STAGE: 0  MAX_STAGE: 0  PROGRESS: 0.000 MEMORY_USED: 67464EXAMINED_ROWS: 0 QUERY_ID: 1457 INFO_BINARY: delete from t0 TID: 8838 *************************** 2. row ***************************  ID: 10  USER: root  HOST: localhost  DB: test  COMMAND: Query  TIME: 0  STATE: Filling schema table  INFO: select * from information_schema.processlist  TIME_MS: 0.805  STAGE: 0  MAX_STAGE: 0  PROGRESS: 0.000 MEMORY_USED: 84576EXAMINED_ROWS: 0 QUERY_ID: 1461 INFO_BINARY: select * from information_schema.processlist TID: 84242 rows in set (0.02 sec)复制代码

...------------TRANSACTIONS------------Trx id counter 20439Purge done for trx's n:o < 20422 undo n:o < 0 state: running but idleHistory list length 176LIST OF TRANSACTIONS FOR EACH SESSION:---TRANSACTION 0, not startedMySQL thread id 11, OS thread handle 0x7f7f5cdb8b00, query id 1457 localhost root Waiting for global read lockdelete from t0---TRANSACTION 0, not startedMySQL thread id 10, OS thread handle 0x7f7f5ce02b00, query id 1462 localhost root initshow engine innodb status--------...复制代码

会话1:flush tables with read lock;Query OK, 0 rows affected (0.00 sec)会话2:mysql> delete from t; --被hang住会话3:mysql> show processlist;+----+------+-----------+------+---------+------+------------------------------+------------------+| Id | User | Host | db | Command | Time | State | Info |+----+------+-----------+------+---------+------+------------------------------+------------------+| 7 | root | localhost | test | Query | 227 | Waiting for global read lock | delete from t || 8 | root | localhost | NULL | Sleep | 215 | | NULL || 9 | root | localhost | NULL | Query | 0 | init | show processlist |+----+------+-----------+------+---------+------+------------------------------+------------------+复制代码

root 7743 2366 0 05:07 ? 00:00:01 /u02/mysql/bin/mysqld 复制代码

(gdb) pset global_thread_list THD*elem[0]: $1 = (THD *) 0x4a55de0elem[1]: $2 = (THD *) 0x4a5cf10elem[2]: $3 = (THD *) 0x4b24aa0Set size = 3 复制代码

(gdb) p ((THD *) 0x4a55de0)->global_read_lock$4 = { static m_active_requests = 1,  m_state = Global_read_lock::GRL_NONE,  m_mdl_global_shared_lock = 0x0,  m_mdl_blocks_commits_lock = 0x0} //这个会话的Global_read_lock为空,不是我们要找的(gdb) p ((THD *) 0x4a5cf10)->global_read_lock$5 = { static m_active_requests = 1,  m_state = Global_read_lock::GRL_NONE,  m_mdl_global_shared_lock = 0x0,  m_mdl_blocks_commits_lock = 0x0} //这个会话的Global_read_lock也为空,不是我们要找的(gdb) p ((THD *) 0x4b24aa0)->global_read_lock$6 = { static m_active_requests = 1,  m_state = Global_read_lock::GRL_ACQUIRED_AND_BLOCKS_COMMIT,  m_mdl_global_shared_lock = 0x7f6034002bb0,  m_mdl_blocks_commits_lock = 0x7f6034002c20} //这个会话的Global_read_lock不为空,GRL_ACQUIRED_AND_BLOCKS_COMMIT表示全局读锁与commit锁,这个就是我们要好的。我接下来打印出它的thread_idp ((THD *) 0x4b24aa0)->thread_id$7 = 8 //8号会话执行了FTWL 复制代码

在新开的mysql会话中,执行下面的语句mysql> kill 8以前被堵在的会话中,会看到下面的结果mysql> delete from t;Query OK, 0 rows affected (40 min 20.73 sec)复制代码

转载于:https://juejin.im/post/5a30d3b751882546d71f54df

你可能感兴趣的文章
Redrain duilib中事件委托存在的问题
查看>>
43、我的C#学习笔记9
查看>>
网站建表实践及优化
查看>>
字符串的简单操作
查看>>
C#新功能--命名参数与可选参数
查看>>
构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(22)-权限管理系统-模块导航制作...
查看>>
strtok和strtok_r
查看>>
维辰超市:借助云商城成功转型新零售
查看>>
[Linux]Web性能测试http_load
查看>>
Airbnb 宣布放弃使用 React Native,回归使用原生技术
查看>>
中外RFID技术差异何在?
查看>>
web.xml中<load-on-start>n</load-on-satrt>作用
查看>>
python之路---进程
查看>>
1061. Dating (20)
查看>>
页面留白问题
查看>>
因为时间少
查看>>
leetcode 【 Best Time to Buy and Sell Stock II 】python 实现
查看>>
推荐15款创建漂亮幻灯片的 jQuery 插件
查看>>
【算法】CRF
查看>>
windows 8 微软拼音输入法
查看>>