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 12 MySQL
详解mysql三值逻辑与NULL
May 19 MySQL
Mysql基础知识点汇总
May 26 MySQL
MySQL 8.0 Online DDL快速加列的相关总结
Jun 02 MySQL
mysql5.7使用binlog 恢复数据的方法
Jun 03 MySQL
MySQL系列之二 多实例配置
Jul 02 MySQL
sql注入教程之类型以及提交注入
Aug 02 MySQL
SQL实现LeetCode(180.连续的数字)
Aug 04 MySQL
一文带你探究MySQL中的NULL
Nov 11 MySQL
MySQL七大JOIN的具体使用
Feb 28 MySQL
MySQL Server层四个日志的实现
Mar 31 MySQL
MySQL串行化隔离级别(间隙锁实现)
Jun 16 MySQL
MySQL磁盘碎片整理实例演示
Mysql使用全文索引(FullText index)的实例代码
Apr 03 #MySQL
一文简单了解MySQL前缀索引
为什么MySQL不建议使用SELECT *
详解MySQL的主键查询为什么这么快
MySQL表锁、行锁、排它锁及共享锁的使用详解
navicat 连接Ubuntu虚拟机的mysql的操作方法
You might like
Windows下PHP的任意文件执行漏洞
2006/10/09 PHP
手把手教你使用DedeCms的采集的图文教程
2007/03/11 PHP
针对thinkPHP5框架存储过程bug重写的存储过程扩展类完整实例
2018/06/16 PHP
使用composer命令加载vendor中的第三方类库 的方法
2019/07/09 PHP
实现laravel 插入操作日志到数据库的方法
2019/10/11 PHP
Javascript 篱式条件判断
2008/08/22 Javascript
Extjs中使用extend(js继承) 的代码
2012/03/15 Javascript
jQuery 无刷新分页实例代码
2013/11/12 Javascript
JavaScript中的变量作用域介绍
2014/12/31 Javascript
jQuery实现表单步骤流程导航代码分享
2015/08/28 Javascript
Bootstrap每天必学之简单入门
2015/11/19 Javascript
Bootstrap基本布局实现方法详解
2016/11/25 Javascript
微信小程序 后台登录(非微信账号)实例详解
2017/03/31 Javascript
详解vuejs之v-for列表渲染
2017/06/22 Javascript
JS实现评价的星星功能
2017/08/20 Javascript
浅谈在vue-cli3项目中解决动态引入图片img404的问题
2020/08/04 Javascript
微信小程序抽奖组件的使用步骤
2021/01/11 Javascript
[00:35]TI7不朽珍藏III——寒冰飞龙不朽展示
2017/07/15 DOTA
用实例分析Python中method的参数传递过程
2015/04/02 Python
python使用MySQLdb访问mysql数据库的方法
2015/08/03 Python
Python之自动获取公网IP的实例讲解
2017/10/01 Python
python中如何使用分步式进程计算详解
2019/03/22 Python
Django ORM多对多查询方法(自定义第三张表&amp;ManyToManyField)
2019/08/09 Python
QT5 Designer 打不开的问题及解决方法
2020/08/20 Python
比利时家具购买网站:Home24
2019/01/03 全球购物
英文求职信写作小建议
2014/02/16 职场文书
董事长助理岗位职责
2014/02/18 职场文书
爱情寄语大全
2014/04/09 职场文书
爱情保证书大全
2014/04/29 职场文书
2014年教学工作总结
2014/11/13 职场文书
大学生逃课检讨书
2015/05/04 职场文书
道士塔读书笔记
2015/06/30 职场文书
格林童话读书笔记
2015/06/30 职场文书
《我和小伙伴》教学反思
2016/02/20 职场文书
创业计划书之酒店
2019/08/30 职场文书
如何设置多台电脑共享打印机?多台电脑共享打印机的方法
2022/04/08 数码科技