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新手入门的基本操作汇总
May 13 MySQL
MYSQL(电话号码,身份证)数据脱敏的实现
May 28 MySQL
带你学习MySQL执行计划
May 31 MySQL
MYSQL 运算符总结
Nov 11 MySQL
Mysql数据库表中为什么有索引却没有提高查询速度
Feb 24 MySQL
解析MySQL索引的作用
Mar 03 MySQL
MySQL Server层四个日志的实现
Mar 31 MySQL
排查并解决MySQL生产库内存使用率高的报警
Apr 11 MySQL
MySQL三种方式实现递归查询
Apr 18 MySQL
解决MySQL报“too many connections“错误
Apr 19 MySQL
mysql 8.0.27 绿色解压版安装教程及配置方法
Apr 20 MySQL
sql查询语句之平均分、最高最低分及排序语句
May 30 MySQL
MySQL磁盘碎片整理实例演示
Mysql使用全文索引(FullText index)的实例代码
Apr 03 #MySQL
一文简单了解MySQL前缀索引
为什么MySQL不建议使用SELECT *
详解MySQL的主键查询为什么这么快
MySQL表锁、行锁、排它锁及共享锁的使用详解
navicat 连接Ubuntu虚拟机的mysql的操作方法
You might like
PHP定时更新程序设计思路分享
2014/06/10 PHP
Symfony学习十分钟入门经典教程
2016/02/03 PHP
Linux(CentOS)下PHP扩展PDO编译安装的方法
2016/04/07 PHP
PHP实现的线索二叉树及二叉树遍历方法详解
2016/04/25 PHP
PHP区块查询实现方法分析
2018/05/12 PHP
解决Laravel blade模板转义html标签的问题
2019/09/03 PHP
javascript函数库-集合框架
2007/04/27 Javascript
AJAX分页的代码(后台asp.net)
2011/02/14 Javascript
JQuery中html()方法使用不当带来的陷阱
2011/04/07 Javascript
DIV+CSS+JS不间断横向滚动实现代码
2013/03/19 Javascript
JQ获取动态加载的图片大小的正确方法分享
2013/11/08 Javascript
JS循环遍历JSON数据的方法
2014/07/08 Javascript
10分钟学会写Jquery插件实例教程
2014/09/06 Javascript
探索angularjs+requirejs全面实现按需加载的套路
2016/02/26 Javascript
jQuery实现下拉框功能实例代码
2016/05/06 Javascript
使用jQuery的load方法设计动态加载及解决被加载页面js失效问题
2017/03/01 Javascript
vue实现登录后页面跳转到之前页面
2018/01/07 Javascript
js判断传入时间和当前时间大小实例(超简单)
2018/01/11 Javascript
详解Nodejs内存治理
2018/05/13 NodeJs
Vue2.0仿饿了么webapp单页面应用详细步骤
2018/07/08 Javascript
node上的redis调用优化示例详解
2018/10/30 Javascript
vue实现的仿淘宝购物车功能详解
2019/01/27 Javascript
解决vue组件没显示,没起作用,没报错,但该显示的组件没显示问题
2020/09/02 Javascript
Vue自定义组件双向绑定实现原理及方法详解
2020/09/03 Javascript
[01:05:40]2014 DOTA2国际邀请赛中国区预选赛 5 23 CIS VS DT第三场
2014/05/24 DOTA
Python实现partial改变方法默认参数
2014/08/18 Python
python下读取公私钥做加解密实例详解
2017/03/29 Python
Python实现常见的回文字符串算法
2018/11/14 Python
python使用gdal对shp读取,新建和更新的实例
2020/03/10 Python
浅谈Django QuerySet对象(模型.objects)的常用方法
2020/03/28 Python
解决Python数据可视化中文部分显示方块问题
2020/05/16 Python
Python爬虫抓取指定网页图片代码实例
2020/07/24 Python
python dir函数快速掌握用法技巧
2020/12/09 Python
八年级语文教学反思
2014/02/11 职场文书
2015年学校政教工作总结
2015/07/20 职场文书
幼儿园保育员随笔
2015/08/14 职场文书