Innodb存储引擎中的后台线程详解


Posted in MySQL onApril 03, 2022

1.maste thread

负责将缓冲池中的数据异步刷新到磁盘,保证数据的一致性。

2.IO Thread

负责IO请求的回调处理。

1.0版本之前有4个IO Thread,负责write、read、insert buffer和log IO Thread

1.0.x开始,read thread和write thread分别增加到4个,不再使用innodb_file_io_threads参数,而是使用innodb_read_io_threads和innodb_write_io_threads

mysql> show variables like 'innodb_version'\G
*************************** 1. row ***************************
Variable_name: innodb_version
        Value: 5.6.25
1 row in set (0.00 sec)
 
mysql> show variables like 'innodb_%io_threads'\G
*************************** 1. row ***************************
Variable_name: innodb_read_io_threads
        Value: 4
*************************** 2. row ***************************
Variable_name: innodb_write_io_threads
        Value: 4
2 rows in set (0.00 sec)
 
mysql> show engine innodb status\G
*************************** 1. row ***************************
  Type: InnoDB
  Name:
Status:
=====================================
2015-12-20 21:53:50 7fcaccfe8700 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 11 seconds
-----------------
BACKGROUND THREAD
-----------------
srv_master_thread loops: 93 srv_active, 0 srv_shutdown, 26243 srv_idle
srv_master_thread log flush and writes: 26336
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 393
OS WAIT ARRAY INFO: signal count 347
Mutex spin waits 297, rounds 8910, OS waits 281
RW-shared spins 53, rounds 1590, OS waits 50
RW-excl spins 13, rounds 1860, OS waits 57
Spin rounds per wait: 30.00 mutex, 30.00 RW-shared, 143.08 RW-excl
------------
TRANSACTIONS
------------
Trx id counter 2545
Purge done for trx's n:o < 2540 undo n:o < 0 state: running but idle
History list length 22
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0, not started
MySQL thread id 5, OS thread handle 0x7fcaccfe8700, query id 491 localhost root init
show engine innodb status
--------
FILE I/O
--------
I/O thread 0 state: waiting for i/o request (insert buffer thread)
I/O thread 1 state: waiting for i/o request (log thread)
I/O thread 2 state: waiting for i/o request (read thread)
I/O thread 3 state: waiting for i/o request (read thread)
I/O thread 4 state: waiting for i/o request (read thread)
I/O thread 5 state: waiting for i/o request (read thread)
I/O thread 6 state: waiting for i/o request (write thread)
I/O thread 7 state: waiting for i/o request (write thread)
I/O thread 8 state: waiting for i/o request (write thread)
I/O thread 9 state: waiting for i/o request (write thread)
Pending normal aio reads: 0 [0, 0, 0, 0] , aio writes: 0 [0, 0, 0, 0] ,
 ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
915 OS file reads, 1496 OS file writes, 1089 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 0, seg size 2, 0 merges
merged operations:
 insert 0, delete mark 0, delete 0
discarded operations:
 insert 0, delete mark 0, delete 0
Hash table size 276671, node heap has 2 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 369664448
Log flushed up to   369664448
Pages flushed up to 369664448
Last checkpoint at  369664448
0 pending log writes, 0 pending chkp writes
356 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 137363456; in additional pool allocated 0
Dictionary memory allocated 96365
Buffer pool size   8191
Free buffers       53
Database pages     8136
Old database pages 2983
Modified db pages  0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages made young 9747, not young 4864716
0.00 youngs/s, 0.00 non-youngs/s
Pages read 4212, created 12449, written 13322
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: 8136, 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
Main thread process no. 2345, id 140508950664960, state: sleeping
Number of rows inserted 3919015, updated 0, deleted 0, read 8532141
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.00 sec)
 
mysql>

3.purge thread

事务提交后,purge thread线程回收已经分配并被使用的undo页。

innodb 1.2开始,支持多个purge thread。

purge thread离散地读取undo页。

mysql> show variables like 'innodb_purge_threads';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| innodb_purge_threads | 1     |
+----------------------+-------+
1 row in set (0.00 sec)
 
mysql>

4.page cleaner thread

1.2.x版本中引入的。将之前版本中脏页的刷新操作都放入到单独的线程中来完成。减轻master thread的工作。

总结

到此这篇关于Innodb存储引擎中后台线程的文章就介绍到这了,更多相关Innodb后台线程内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!

MySQL 相关文章推荐
Mysql 性能监控及调优
Apr 06 MySQL
MySQL 慢查询日志深入理解
Apr 22 MySQL
MySQL分库分表与分区的入门指南
Apr 22 MySQL
MySQL 如何设计统计数据表
Jun 15 MySQL
浅析MySQL如何实现事务隔离
Jun 26 MySQL
MySql 缓存查询原理与缓存监控和索引监控介绍
Jul 02 MySQL
浅谈MySQL之select优化方案
Aug 07 MySQL
mysql创建存储过程及函数详解
Dec 04 MySQL
MySQL分区表管理命令汇总
Mar 21 MySQL
MySQL分区路径子分区再分区
Apr 13 MySQL
MySQL数据库实验实现简单数据库应用系统设计
Jun 21 MySQL
面试官问我Mysql的存储引擎了解多少
Aug 05 MySQL
MySQL磁盘碎片整理实例演示
Mysql使用全文索引(FullText index)的实例代码
Apr 03 #MySQL
一文简单了解MySQL前缀索引
为什么MySQL不建议使用SELECT *
详解MySQL的主键查询为什么这么快
MySQL表锁、行锁、排它锁及共享锁的使用详解
navicat 连接Ubuntu虚拟机的mysql的操作方法
You might like
深入解析PHP的引用计数机制
2013/06/14 PHP
浅析php header 跳转
2013/06/17 PHP
ThinkPHP实现ajax仿官网搜索功能实例
2014/12/02 PHP
PHP递归调用数组值并用其执行指定函数的方法
2015/04/01 PHP
PHP人民币金额转大写实例代码
2015/10/02 PHP
PHP中创建和编辑Excel表格的方法
2018/09/13 PHP
PHP使用POP3读取邮箱接收邮件的示例代码
2020/07/08 PHP
javascript中的作用域scope介绍
2010/12/28 Javascript
jQuery EasyUI API 中文文档 - Draggable 可拖拽
2011/09/29 Javascript
php 中序列化和json使用介绍
2013/07/08 Javascript
js限制checkbox选中个数以限制六个为例
2014/07/15 Javascript
JS数组array元素的添加和删除方法代码实例
2015/06/01 Javascript
JavaScript File API文件上传预览
2016/02/02 Javascript
js表单验证实例讲解
2016/03/31 Javascript
微信小程序 前端源码逻辑和工作流详解
2016/10/08 Javascript
Javascript计算二维数组重复值示例代码
2016/12/18 Javascript
Vue如何将页面导出成PDF文件
2020/08/17 Javascript
利用Python+Java调用Shell脚本时的死锁陷阱详解
2018/01/24 Python
Python3数据库操作包pymysql的操作方法
2018/07/16 Python
基于Python3.6+splinter实现自动抢火车票
2018/09/25 Python
python实现推箱子游戏
2020/03/25 Python
Python爬虫爬取Bilibili弹幕过程解析
2019/10/10 Python
python 通过邮件控制实现远程控制电脑操作
2020/03/16 Python
解决pycharm下pyuic工具使用的问题
2020/04/08 Python
python实现canny边缘检测
2020/09/14 Python
matplotlib绘制多子图共享鼠标光标的方法示例
2021/01/08 Python
matplotlib之属性组合包(cycler)的使用
2021/02/24 Python
html5使用canvas绘制一张图片
2014/12/15 HTML / CSS
英国复古皮包品牌:Beara Beara
2018/07/18 全球购物
澳大利亚领先的优质葡萄酒拍卖会:Langton’s Fine Wines
2019/03/24 全球购物
运动员入场词
2015/07/18 职场文书
2019年朋友圈经典励志语录50条
2019/07/05 职场文书
nginx基于域名,端口,不同IP的虚拟主机设置的实现
2021/03/31 Servers
浅谈Python从全局与局部变量到装饰器的相关知识
2021/06/21 Python
MySQL高级进阶sql语句总结大全
2022/03/16 MySQL
日本动漫十大公认神作:第五现已全网禁播,《死亡笔记》在榜
2022/03/18 日漫