Bug #86865 | InnoDB does unnecessary work when extending a tablespace | ||
---|---|---|---|
Submitted: | 29 Jun 2017 8:09 | Modified: | 19 Oct 2020 14:17 |
Reporter: | Alexey Kopytov | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
Version: | 5.7, 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[29 Jun 2017 8:09]
Alexey Kopytov
[29 Jun 2017 14:48]
OCA Admin
Contribution submitted via Github - Bug #86865: InnoDB does unnecessary work when extending a tablespace (*) Contribution by Alexey Kopytov (Github akopytov, mysql-server/pull/152#issuecomment-311943498): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: git_patch_128093743.txt (text/plain), 1.33 KiB.
[30 Jun 2017 15:25]
MySQL Verification Team
Hi Kaamos, my friend, My opinion is that this is truly waste of resources, so I am verifying this bug. Thank you very much for your patch and the entire contribution. The only small caveat that I have is that there may be some library version, out there , which does not do automatic zerofill on posix_fallocate(). Hence, some additional checks might be required with our configuration sctipts. Thanks again !!!!!!
[11 Apr 2018 7:30]
zhai weixiang
hi, Alexey i think it makes sense to skip filling zero. Just one case: the crash recovery will only treate full zero page as a clean one, otherwise if the page is not initialized by filling zero, it may consider it as corrupted and refuse to startup. But this can be workaround during crash recovery: check if the first redo log of the page is MLOG_INIT_FILE_PAGE
[19 Oct 2020 14:17]
Alexey Kopytov
This appears to be fixed in 8.0.22. From the release notes: "The new innodb_extend_and_initialize variable permits configuring how InnoDB allocates space to file-per-table and general tablespaces on Linux. By default, when an operation requires additional space in a tablespace, InnoDB allocates pages to the tablespace and physically writes NULLs to those pages. This behavior affects performance if new pages are allocated frequently. As of MySQL 8.0.22, you can disable innodb_extend_and_initialize on Linux systems to avoid physically writing NULLs to newly allocated tablespace pages. When innodb_extend_and_initialize is disabled, space is allocated using posix_fallocate() calls, which reserve space without physically writing NULLs. A posix_fallocate() operation is not atomic, which makes it possible for a failure to occur between allocating space to a tablespace file and updating the file metadata. Such a failure can leave newly allocated pages in an uninitialized state, resulting in a failure when InnoDB attempts to access those pages. To prevent this scenario, InnoDB writes a redo log record before allocating a new tablespace page. If a page allocation operation is interrupted, the operation is replayed from the redo log record during recovery."
[20 Oct 2020 12:18]
MySQL Verification Team
Hi Alexey, Yes, you are correct. Thanks a lot ........