MySQL5.7 can reclaim (shrink) Undo Log Rollback Log physical file space

Source: Internet
Author: User
Tags log log

The Undo log rollback log is saved in the shared tablespace ibdata1 file, and as the business keeps running, the ibdata1 file becomes larger and more difficult and complex to reclaim (shrinking space size), you must first mysqldump-a the entire library and then delete the data directory, Then re-initialize the installation, and finally the whole library of SQL file import, using this method to Ibdata1 file recovery.


In MySQL5.6, the Undo log rollback logs can be separated out into a separate table space, please refer to: http://hcymysql.blog.51cto.com/5223301/973450, but the drawback is that you cannot reclaim (shrink) the size of the space. Online shrinkage is not supported until MySQL5.7.

The Innodb_undo_log_truncate parameter is set to 1, which enables the online recycle (shrink) Undo log log file to support dynamic settings. The innodb_undo_tablespaces parameter must be greater than or equal to 2, that is, when you recycle (shrink) An undo log log file, make sure that another undo log is available. Innodb_undo_logs:undo the number of rollback segments, at least greater than or equal to 35, by default of 128. Innodb_max_undo_log_size: When this threshold is exceeded (the default is 1G), the truncate recovery (contraction) action is triggered, and the truncate space is reduced to 10M. Innodb_purge_rseg_truncate_frequency: Controls how often the undo log is recycled (shrunk). The Undo log space does not shrink until its rollback segment is released, and to increase the frequency of releasing the rollback interval, the Innodb_purge_rseg_truncate_frequency setting value is lowered.

Verification process:
For a 1 million sbtest table, update the whole table 4 times, such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4E/53/wKioL1RgdBOBBGZbAAJUujfvDjw197.jpg "title=" cc.jpg "alt=" Wkiol1rgdbobbgzbaajuujfvdjw197.jpg "/>


You will then find the undo log space growing rapidly, such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4E/55/wKiom1Rgc-mhJySsAADkvtWGqPo071.jpg "title=" aa.jpg "alt=" Wkiom1rgc-mhjyssaadkvtwgqpo071.jpg "/>


Then use Sysbench to do the stress test, let the database run, observe the error log, will automatically put the undo log space for recycling (contraction), such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4E/54/wKioL1RgdRGzrwuGAAPmBf1k6iA093.jpg "title=" bb.jpg "alt=" Wkiol1rgdrgzrwugaapmbf1k6ia093.jpg "/>


Again by observing the physical file, the default 10M size has been recycled.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4E/55/wKioL1RgdYDhQQhEAADjmLNYACA460.jpg "title=" dd.jpg "alt=" Wkiol1rgdydhqqheaadjmlnyaca460.jpg "/>


Summarize:

This feature reduces disk space usage (local tyrants, of course), and speeds up the xtrabackup hot backup.




This article is from the "Spring Yang Technical column" blog, please be sure to keep this source http://hcymysql.blog.51cto.com/5223301/1575050

MySQL5.7 can reclaim (shrink) Undo Log Rollback Log physical file space

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.