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 InnoDB存储引擎的内存管理
Apr 08 MySQL
MySQL root密码的重置方法
Apr 21 MySQL
MySQL 角色(role)功能介绍
Apr 24 MySQL
MySQL查询学习之基础查询操作
May 08 MySQL
解决Navicat for Mysql连接报错1251的问题(连接失败)
May 27 MySQL
解决Mysql的left join无效及使用的注意事项说明
Jul 01 MySQL
MySQL 8.0 驱动与阿里druid版本兼容问题解决
Jul 01 MySQL
MySQL深度分页(千万级数据量如何快速分页)
Jul 25 MySQL
深入解析MySQL索引数据结构
Oct 16 MySQL
WINDOWS 64位 下安装配置mysql8.0.25最详细的教程
Mar 22 MySQL
解决Mysql报错 Table 'mysql.user' doesn't exist
May 06 MySQL
MySQL选择合适的备份策略和备份工具
Jun 01 MySQL
MySQL磁盘碎片整理实例演示
Mysql使用全文索引(FullText index)的实例代码
Apr 03 #MySQL
一文简单了解MySQL前缀索引
为什么MySQL不建议使用SELECT *
详解MySQL的主键查询为什么这么快
MySQL表锁、行锁、排它锁及共享锁的使用详解
navicat 连接Ubuntu虚拟机的mysql的操作方法
You might like
深入探讨:Nginx 502 Bad Gateway错误的解决方法
2013/06/03 PHP
深入解析phpCB批量转换的代码示例
2013/06/27 PHP
php获取bing每日壁纸示例分享
2014/02/25 PHP
PHP中使用Imagick实现各种图片效果实例
2015/01/21 PHP
CI框架源码解读之利用Hook.php文件完成功能扩展的方法
2016/05/18 PHP
php基于 swoole 实现的异步处理任务功能示例
2019/08/13 PHP
php 多继承的几种常见实现方法示例
2019/11/18 PHP
javascript js cookie的存储,获取和删除
2007/12/29 Javascript
jQuery 操作XML入门
2008/12/25 Javascript
入门基础学习 ExtJS笔记(一)
2010/11/11 Javascript
ie8模式下click无反应点击option无反应的解决方法
2014/10/11 Javascript
iframe里面的元素触发父窗口元素事件的jquery代码
2014/10/19 Javascript
JavaScript中模拟实现jsonp
2015/06/19 Javascript
vue-router2.0 组件之间传参及获取动态参数的方法
2017/11/10 Javascript
bootstrap响应式工具使用详解
2017/11/29 Javascript
Layer弹出层动态获取数据的方法
2018/08/20 Javascript
JS中的一些常用的函数式编程术语
2019/06/15 Javascript
vuex 动态注册方法 registerModule的实现
2019/07/03 Javascript
解决微信小程序中的滚动穿透问题
2019/09/16 Javascript
vue实现百度语音合成的实例讲解
2019/10/14 Javascript
vue基础知识--axios合并请求和slot
2020/06/04 Javascript
Javascript中的奇葩知识,你知道吗?
2021/01/25 Javascript
Python中还原JavaScript的escape函数编码后字符串的方法
2014/08/22 Python
在Python中移动目录结构的方法
2016/01/31 Python
Python3.5内置模块之shelve模块、xml模块、configparser模块、hashlib、hmac模块用法分析
2019/04/27 Python
使用 pytorch 创建神经网络拟合sin函数的实现
2020/02/24 Python
pyinstaller打包成无控制台程序时运行出错(与popen冲突的解决方法)
2020/04/15 Python
Python爬虫爬取博客实现可视化过程解析
2020/06/29 Python
Html5自定义字体解决方法
2019/10/09 HTML / CSS
Toppik顶丰增发纤维官网:解决头发稀疏
2017/12/30 全球购物
美国最古老的精致书写工具制造商:A.T. Cross(高仕)
2018/01/30 全球购物
英国领先的新鲜松露和最好的松露产品供应商:TruffleHunter
2019/08/26 全球购物
Linux如何压缩可执行文件
2013/10/21 面试题
八年级美术教学反思
2014/02/02 职场文书
前处理班长职位说明书
2014/03/01 职场文书
《暗黑破坏神2:重制版》本周进行第一轮A测 目前可官网进行申请报名
2021/04/07 其他游戏