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中VARCHAR与CHAR格式数据的区别
May 26 MySQL
解决Mysql的left join无效及使用的注意事项说明
Jul 01 MySQL
MySQL query_cache_type 参数与使用详解
Jul 01 MySQL
MySQL系列之九 mysql查询缓存及索引
Jul 02 MySQL
Mysql排序的特性详情
Nov 01 MySQL
MySQL高级进阶sql语句总结大全
Mar 16 MySQL
MySQL优化及索引解析
Mar 17 MySQL
Linux系统下MySQL配置主从分离的步骤
Mar 21 MySQL
MySQL数据库Innodb 引擎实现mvcc锁
May 06 MySQL
mysql如何查询连续记录
May 11 MySQL
mysql sock 文件解析及作用讲解
Jul 15 MySQL
MySQL磁盘碎片整理实例演示
Mysql使用全文索引(FullText index)的实例代码
Apr 03 #MySQL
一文简单了解MySQL前缀索引
为什么MySQL不建议使用SELECT *
详解MySQL的主键查询为什么这么快
MySQL表锁、行锁、排它锁及共享锁的使用详解
navicat 连接Ubuntu虚拟机的mysql的操作方法
You might like
php中iconv函数使用方法
2008/05/24 PHP
discuz论坛 用户登录 后台程序代码
2008/11/27 PHP
PHP isset()与empty()的使用区别详解
2010/08/29 PHP
php去掉字符串的最后一个字符附substr()的用法
2011/03/23 PHP
php验证session无效的解决方法
2014/11/04 PHP
thinkphp模板输出技巧汇总
2014/11/24 PHP
Yii2中YiiBase自动加载类、引用文件方法分析(autoload)
2016/07/25 PHP
php通过执行CutyCapt命令实现网页截图的方法
2016/09/30 PHP
PHP获取页面执行时间的方法(推荐)
2016/12/10 PHP
滚动条变色 隐藏滚动条与双击网页自动滚屏显示代码
2009/12/28 Javascript
js 创建快捷方式的代码(fso)
2010/11/19 Javascript
JavaScript中的细节分析
2012/06/30 Javascript
js/jquery获取浏览器窗口可视区域高度和宽度以及滚动条高度实现代码
2012/12/17 Javascript
现代 JavaScript 开发编程风格Idiomatic.js指南中文版
2014/05/28 Javascript
jQuery中$.get、$.post、$.getJSON和$.ajax的用法详解
2014/11/19 Javascript
Backbone.js框架中简单的View视图编写学习笔记
2016/02/14 Javascript
Javascript 实现全屏滚动实例代码
2016/12/31 Javascript
Angular在一个页面中使用两个ng-app的方法
2017/02/20 Javascript
详解Node全局变量global模块
2017/09/28 Javascript
vue基础之使用get、post、jsonp实现交互功能示例
2019/03/12 Javascript
Python基于回溯法子集树模板解决马踏棋盘问题示例
2017/09/11 Python
python RabbitMQ 使用详细介绍(小结)
2018/11/08 Python
python SQLAlchemy的Mapping与Declarative详解
2019/07/04 Python
在SQLite-Python中实现返回、查询中文字段的方法
2019/07/17 Python
Python绘制股票移动均线的实例
2019/08/24 Python
python全局变量引用与修改过程解析
2020/01/07 Python
python中doctest库实例用法
2020/12/31 Python
利物浦足球俱乐部官方网上商店:Liverpool FC Official Store
2018/01/13 全球购物
日本热销NO.1胶原蛋白冻:Aishitoto爱希特多
2019/06/20 全球购物
假日旅行社实习自我鉴定
2013/09/24 职场文书
超市总经理岗位职责
2014/02/02 职场文书
小学生暑假家长评语
2014/04/17 职场文书
经济贸易专业自荐信
2014/06/11 职场文书
2014幼儿园中班工作总结
2014/11/10 职场文书
安全知识竞赛主持词
2015/06/30 职场文书
Python+uiautomator2实现自动刷抖音视频功能
2021/04/29 Python