Double Write buffer for InnoDB

Source: Internet
Author: User

    Yesterday saw InnoDB's double write buffer, the book said not too detailed, online also conform. Think for some time, finally have some clue.
    First of all, why do I need a double write buffer? Because the page size of the INNODB and operating system is inconsistent, the InnoDB page size is generally 16k, the operating system page size is 4k, resulting in InnoDB write-back dirty data to the operating system, a page needs to write 4 times, the writing process problems can not maintain atomicity. If the process of writing crashes or loses power, it may result in only a fraction of the data being written back into the operating system file system, which is only partially successful, in fact the data is corrupted.
If you need to ensure the success of the data, and do not adopt a double write buffer, there is a more stupid way, the redo log records the entire change of page data, write back from the redo log to copy the page data to the file system, which will lead to redo log is very large, may bring great problems to the system performance. The
uses the double write buffer, the redo log only needs to record very few change information, the original data still exists in the original file system, writes to Doublewrite Buffer, calculates the new data according to redo log and the metadata information, first writes to the Doublewrite In buffer. If the system crashes at this point, InnoDB can calculate the check bit after recovery, know that the data is incorrect, and re-generate data from the redo log and metadata to overwrite the corrupted data in the Doublewrite buffer. When all data in Doublewrite buffer is successfully written, Doublewrite Buffer writes the data to the file system, and if the system crashes at this point, it only needs to traverse Doublewrite buffer to re-write the data to the file system. Overwrite the corrupted data.
    Because the book and the Internet have been vague, have been thinking why doublewrite buffer, if not is also feasible, the answer is not also feasible, but this requires redo log records all the changed page data, Can cause redo logs to be particularly large. If the redo log only records change is it feasible? This can be problematic, because if you write directly to the file system, if the data is corrupted, the original data is overwritten, and the new correct data cannot be calculated separately based on the redo log that contains only the change information. So doublewrite buffer is the equivalent of the medium of storage in the middle state, which may lead to more IO, but because doublewrite buffer is sequential write, it should affect not too much, the data correctness and redo log size is controlled, benefit greatly outweigh the disadvantages.

Double Write buffer for InnoDB

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.