MySQL Double Write, mysqldouble

Source: Internet
Author: User
Tags percona

MySQL Double Write, mysqldouble
When the Double Write feature is not available

 

After the data is updated, the dirty page is placed in the innodb buffer cache. The checksum value of the page changes.

In the header of the page, the fileheader contains the checksum item named file_page_space_or_checksum.

The filetailer part at the end of the page is also used to compare the checksum item, named file_page_end_lsn.

They use special checksum functions for comparison to verify page integrity.

Here we simply understand it as an equivalent comparison.

 

 







At this time, refresh the disk. If only 8 KB is written on the 16 KB page, an exception occurs, and the server power is down and the MySQL instance is suddenly stopped. At this time, the partial page write problem occurs, that is, only part of the page data is synchronized to the disk.

Checksum fails.

 

 

 

In fact, the Innodb of MySQL and the redo log of the Oracle database do not record purely physical operations, but logs that combine physical and logical operations. (This can reduce redo generation)

 

Physical to page, that is, the specific location of the page on the hard disk.

The subsequent page operations are stored logically based on the format (Specific parsing functions are required for applications). For example, a record is inserted into the page.

 

Of course, Oracle databases are similar, physical, and only block-level.

 

 

Therefore, when the page is damaged, applying redo is meaningless.

 

 

 

At this time, you cannot use redo to restore the data because the original page is damaged.

Data will be lost.

 

 





When the doublewrite feature is available



When writing dirty data to the disk, the dirty page is first copied to the 2 MB double write buffer memory area through the memcpy function.

Then, the first step of double write buffer writes the 2 mb data to the allocated double write area in the shared tablespace each time.

Step 2: Write the data page to the data file.



When a fault occurs in step 2, that is, partial page write occurs.

 

 








First, check whether the checksum in the page is the same.

 

 







Otherwise, it will be restored directly from doublewrite.

 

 







Of course, if the checksum of the page passes but is different from the checksum in doublewrite, you can directly apply the redo log to perform the restoration operation.

 

 

This article only introduces the content related to double write. The crash recovery process is much more complicated. For more information, please go to the following link to find the answer.


 

 

References:

MySQL database InnoDB Storage engine Log roaming

Http://www.uml.org.cn/sjjm/201205222.asp

 

Innodb Double Write

Http://www.percona.com/blog/2006/08/04/innodb-double-write/

 

Configuration of the Doublewrite Buffer

Http://www.percona.com/doc/percona-server/5.5/performance/innodb_doublewrite_path.html? Id = percona-server: features: percona_innodb_doublewrite_path

 

Source code implementation of InnoDB Crash Recovery process

Http://hedengcheng.com /? P = 183

Related Article

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.