How the InnoDB master thread works

Source: Internet
Author: User
Tags goto

We simply communicate under InnoDB Master thread learning, interested friends can refer to <<mysql technology Inner Mongolia--innodb Storage Engine Second Edition >>

void Master_thread () {goto loop;loop: for(intI=0;i<Ten; i++) {Thread_sleep (1)//Sleep 1 second--> per second (load is delayed in case)     DoLog buffer flush to disk//redo log buffers are flushed to disk, even if the transaction is not committed (always)    if(Last_ten_second_ios <5% innodb_io_capacity)//if the current number of 10 times is less than (5% * 200=10) (innodb_io_capacity default value is $)         DoMerger5% innodb_io_capacity Insert Buffer//perform 10 Merge Insert buffering operations (5% * 200=10)    if(buf_get_modified_ratio_pct > innodb_max_dirty_pages_pct)//if the dirty page ratio in the buffer pool is greater than innodb_max_dirty_pages_pct (default is 75 o'clock)         DoBuffer Pool Plush -% innodb_io_capacity Dirty page//Refresh 200 dirty pages to disk    Else ifEnable Adaptive flush//If you open an account, adaptive refresh         DoBuffer pool Flush Desired Amount Dirty page//determine the most appropriate number of dirty pages to refresh by judging the speed at which the redo log is generated    if(No user activity)//If there is currently no user activityGoto Backgroud Loop//Skip to Background loop}//operations performed every 10 secondsif(Last_ten_second_ios < innodb_io_capacity)//if the number of disk IO times in the past 10 is less than the set innodb_io_capacity value (by default)     DoBuffer Pool Flush -% innodb_io_capacity Dirty page//refreshes the number of dirty pages as innodb_io_capacity (by default) DoMerger5% innodb_io_capacity Insert Buffer//Merge Insert buffer is innodb_io_capacity 5% (10) (always) DoLog buffer flush to disk//redo log buffers are flushed to disk, even if the transaction is not committed (always) DoFull purge//Delete useless undo page (always)if(Buf_get_modified_ratio_pct > -%)//if the ratio of WINS pages in the buffer pool is greater than 70%     DoBuffer Pool Flush -% innodb_io_capacity Dirty page//Refresh 200 dirty pages to diskElse     DoBuffer Pool FlushTen% innodb_io_capacity Dirty page//Otherwise refresh 20 dirty pages to diskgoto Loopbackgroud Loop://Background Loop DoFull purge//Delete useless undo page (always) DoMerger5% innodb_io_capacity Insert Buffer//Merge Insert buffer is innodb_io_capacity 5% (10) (always)ifNot idle://if it is not idle, jump back to the main loop, and if idle, jump into the flush loopGoto Loop://Skip to main loopElse: Goto flush Loopflush Loop://Refresh Loop Dobuf_get_modified_ratio_pct Pool Flush -% innodb_io_capacity Dirty page//Refresh 200 dirty pages to diskif(buf_get_modified_ratio_pct > innodb_max_dirty_pages_pct)//if the dirty page ratio in the buffer pool is greater than the value of innodb_max_dirty_pages_pct (default 75%)Goto Flush Loop//skip to refresh cycle, refresh dirty pages continuously until eligibleGoto Suspend Loop//after completing the task of refreshing the dirty page, jump into the suspend loopsuspend Loop:suspend_thread ()//master thread hangs, waits for event to occurwaiting Eventgoto Loop;}

How the InnoDB master thread works

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.