MySQL技术内幕InnoDB存储引擎 - 后台线程

1、Master Thread
一个非常核心的后台线程。
主要负责将缓冲池中的数据异步刷新到磁盘,
保证数据的一致性:包括脏页的刷新、合并插入缓冲( INSERT BUFFER )、UNDO 页的回收等。
随着版本的发展,不少工作分出去给其他线程去做了:
  a、UNDO 页的回收工作交给 Purge Thead
  b、脏页的刷新工作交给 Page Cleaner Thread
 
 
2、IO Thread
InnoDB中大量使用了AIO(Async IO)处理写IO的请求以提交性能,
IO Thread的主要工作就是处理这些IO请求的回调处理。
通过下面的命令可以查看 io 线程的数量:
SHOW VARIABLES LIKE 'innodb_%io_threads';

innodb_read_io_threads    4
innodb_write_io_threads    4

也可以通过 查看每个:

show engine innodb status

...
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
I/O thread 3 state: waiting for completed aio requests (read thread)
I/O thread 4 state: waiting for completed aio requests (read thread)
I/O thread 5 state: waiting for completed aio requests (read thread)
I/O thread 6 state: waiting for completed aio requests (write thread)
I/O thread 7 state: waiting for completed aio requests (write thread)
I/O thread 8 state: waiting for completed aio requests (write thread)
I/O thread 9 state: waiting for completed aio requests (write thread)
Pending normal aio reads: [0, 0, 0, 0] , aio writes: [0, 0, 0, 0] ,
 ibuf aio reads:, log i/o's:, sync i/o's:
Pending flushes (fsync) log: 0; buffer pool: 3
1627 OS file reads, 1175632 OS file writes, 477732 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.54 writes/s, 0.23 fsyncs/s
...

 

3、Purge Thread

负责回收和分配 undo页。

SHOW VARIABLES LIKE 'innodb_purge_threads'

innodb_purge_threads    4

 

4、Page Cleaner Thread

负责脏页的刷新操作。

 

posted on 2020-01-26 13:18  HB1  阅读(408)  评论(0)    收藏  举报

导航