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 24 MySQL
mysql在项目中怎么选事务隔离级别
May 25 MySQL
MySQL连表查询分组去重的实现示例
Jul 01 MySQL
分享mysql的current_timestamp小坑及解决
Nov 27 MySQL
VS2019连接MySQL数据库的过程及常见问题总结
Nov 27 MySQL
JMeter对MySQL数据库进行压力测试的实现步骤
Jan 22 MySQL
MySQL 数据表操作
May 04 MySQL
单机多实例部署 MySQL8.0.20
May 15 MySQL
MySQL数据库简介与基本操作
May 30 MySQL
mysql实现将字符串字段转为数字排序或比大小
Jun 14 MySQL
mysql幻读详解实例以及解决办法
Jun 16 MySQL
MySQL的表级锁,行级锁,排它锁和共享锁
Jul 15 MySQL
MySQL磁盘碎片整理实例演示
Mysql使用全文索引(FullText index)的实例代码
Apr 03 #MySQL
一文简单了解MySQL前缀索引
为什么MySQL不建议使用SELECT *
详解MySQL的主键查询为什么这么快
MySQL表锁、行锁、排它锁及共享锁的使用详解
navicat 连接Ubuntu虚拟机的mysql的操作方法
You might like
php sprintf()函数让你的sql操作更安全
2008/07/23 PHP
php批量删除操作(数据访问)
2017/05/23 PHP
Centos7安装swoole扩展操作示例
2020/03/26 PHP
JavaScript 事件参考手册
2008/12/24 Javascript
javascript 复杂的嵌套环境中输出单引号和双引号
2009/05/26 Javascript
基于jquery的仿百度搜索框效果代码
2011/04/11 Javascript
JS打开新窗口的2种方式
2013/04/18 Javascript
jquery 获取标签名(tagName)示例代码
2013/07/11 Javascript
利用js实现前台动态添加文本框,后台获取文本框内容(示例代码)
2013/11/25 Javascript
以JavaScript来实现WordPress中的二级导航菜单的方法
2015/12/14 Javascript
JS+HTML5 FileReader实现文件上传前本地预览功能
2020/03/27 Javascript
nodejs超出最大的调用栈错误问题
2017/12/27 NodeJs
Vue-cli3项目配置Vue.config.js实战记录
2018/07/29 Javascript
JavaScript设计模式之责任链模式实例分析
2019/01/16 Javascript
layui实现数据分页功能(ajax异步)
2019/07/27 Javascript
vue常用高阶函数及综合实例
2021/02/25 Vue.js
从零学python系列之浅谈pickle模块封装和拆封数据对象的方法
2014/05/23 Python
使用Python的Scrapy框架编写web爬虫的简单示例
2015/04/17 Python
Python中用于计算对数的log()方法
2015/05/15 Python
Python使用文件锁实现进程间同步功能【基于fcntl模块】
2017/10/16 Python
Tensorflow分类器项目自定义数据读入的实现
2019/02/05 Python
Python使用sklearn库实现的各种分类算法简单应用小结
2019/07/04 Python
基于Django快速集成Echarts代码示例
2020/12/01 Python
爱尔兰电子产品购物网站:Komplett.ie
2018/04/04 全球购物
亚马逊意大利站点:Amazon.it
2020/12/31 全球购物
工作自荐信
2013/12/11 职场文书
班组长安全生产职责
2013/12/16 职场文书
写好自荐信的几个要点
2013/12/26 职场文书
社会实践心得体会
2014/01/03 职场文书
战友聚会邀请函
2014/01/18 职场文书
服务之星获奖感言
2014/01/21 职场文书
团购业务员岗位职责
2014/03/15 职场文书
孝敬父母的演讲稿
2014/05/14 职场文书
maven依赖的version声明控制方式
2022/01/18 Java/Android
Win11应用商店打开闪退怎么解决? win11应用商店打不开的多种解决办法
2022/04/05 数码科技
Java无向树分析 实现最小高度树
2022/04/09 Javascript