innodb purge线程的创建

innobase_start_or_create_for_mysql:
	if (!srv_read_only_mode && srv_force_recovery < SRV_FORCE_NO_BACKGROUND) {
		os_thread_create(srv_purge_coordinator_thread,
			NULL, thread_ids + 5 + SRV_MAX_N_IO_THREADS);

		/* We've already created the purge coordinator thread above. */
		for (i = 1; i < srv_n_purge_threads; ++i) {
			os_thread_create(srv_worker_thread, NULL,
				thread_ids + 5 + i + SRV_MAX_N_IO_THREADS);
		}

		srv_start_wait_for_purge_to_start();//等待coordinate thread和master thread启动

	} else {
		purge_sys->state = PURGE_STATE_DISABLED;
	}

Purge线程分为2类,一类是coordinatorthread,只有一个这样的线程。另外innodb_purge_threads-1个是worker thread。线程在innodb启动时创建。

 

在innodb_force_recovery>=2的情况下,没有创建purge线程。禁用purge。

enum {
	SRV_FORCE_IGNORE_CORRUPT = 1,/*!< let the server run even if it detects a corrupt page */
	SRV_FORCE_NO_BACKGROUND	= 2,	/*!< prevent the main thread

你可能感兴趣的:(MySQL源码分析,MySQL源码研究)