后台线程
Master Thread
Master Thread
是一个非常核心的后台线程,主要负责将缓冲池中的数据异步刷新到磁盘,保证数据的一致性:包括脏页的刷新
、合并插入缓冲(INSERT BUFFER)
、UNDO页的回收
等。
IO Thread
引擎使用大量AIO(Async IO)来处理IO请求,这样可以极大提高数据库的性能。
IO Thread的主要工作是负责这些IO请求的回调(call back)处理
。有4类IO Thread,分别是write
、read
、insert buffer
、log IO thread
。(InnoDB 1.0.x,read thread
和write thread
增多到4个,可调。)
mysql> show variables like 'innodb_%io_threads';
+-------------------------+-------+
| Variable_name | Value |
+-------------------------+-------+
| innodb_read_io_threads | 4 |
| innodb_write_io_threads | 4 |
+-------------------------+-------+
mysql> 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)
Purge Thread
事务提交后,其所使用的undolog可能不再需要,因此需要Purge Thread
来回收已使用并分配的undo页
。
之前purge操作仅在Master Thread中完成。新版本后,purge操作可以独立到单独的线程中进行,以此减轻Master Thread的工作,从而提高CPU的使用率以及提升存储引擎的性能。
Page Cleaner Thread
作用是将之前版本中脏页的刷新
操作都放入到单独线程中来完成。
目的是为了减轻原Master Thread的工作及对用户查询线程的阻塞,进一步提高InnoDB存储引擎的性能。