master thread

mysql 中最重要的 daemon 线程,控制了大部分的后台工作

 

/** Types of threads existing in the system. */ enum srv_thread_type { SRV_COM = 1, /**< threads serving communication and queries */ SRV_CONSOLE, /**< thread serving console */ SRV_WORKER, /**< threads serving parallelized queries and queries released from lock wait */ #if 0 /* Utility threads */ SRV_BUFFER, /**< thread flushing dirty buffer blocks */ SRV_RECOVERY, /**< threads finishing a recovery */ SRV_INSERT, /**< thread flushing the insert buffer to disk */ #endif SRV_MASTER /**< the master thread, (whose type number must be biggest) */ };

 

/* 主要做以下几件事 1。doing background drop tables,drop tables which we must drop in background after queries to them have ended 2。Flush logs if needed 3。do an insert buffer merge 4。flushing buffer pool dirty pages 主分每1秒做一次和每10做一次,区别是每1秒做的,条件限制严格,做的量比较少;每10秒做的,最后还要making checkpoint 当没有新的连接进入时,系统就进入 background_loop 和 flush_loop 不再进入前面的循环当中,这时消耗的CPU,内存较低,线程进入wait event状态,相当于休眠 在TPS的bench mark中,过一段时间,性能的明显下降就是由于flushing buffer pool dirty pages引起的,mysql引入了adaptive flushing 主要就是在每1秒的循环中,把这1秒比平均的多出来的flush, 不用等到每10秒时flush时一块做 */

 

 

 

 

 

你可能感兴趣的:(thread,mysql,buffer,insert,merge,Types)