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后台线程内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!