[MDEV-24626] Remove synchronous write of page0 and flushing file during file creation Created: 2021-01-19  Updated: 2023-12-04  Resolved: 2021-05-17

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.6.1

Type: Bug Priority: Blocker
Reporter: Thirunarayanan Balathandayuthapani Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-14481 Execute InnoDB crash recovery in the ... Closed
blocks MDEV-25646 Atomic DDL: InnoDB: Datafile './test... Closed
Problem/Incident
causes MDEV-25967 Server restarted on backupped data cr... Closed
causes MDEV-26326 MDEV-24626 (remove synchronous page0 ... Closed
causes MDEV-27817 InnoDB recovery of recently created f... Closed
causes MDEV-28923 atomic.rename_table occasionally fails Closed
causes MDEV-28974 mariadb-backup --prepare fails to pre... Closed
causes MDEV-28977 Race condition in the recovery of CRE... Closed
causes MDEV-30069 InnoDB: Trying to write ... bytes at ... Closed
causes MDEV-31098 InnoDB Recovery doesn't display encry... Closed
Relates
relates to MDEV-25655 Atomic DDL: InnoDB: Cannot replay ren... Closed
relates to MDEV-25665 safe_mutex: Trying to lock mutex ... ... Closed
relates to MDEV-25852 Orphan #sql*.ibd files are occasional... Closed
relates to MDEV-25909 Unnecessary calls to fil_ibd_load() s... Open
relates to MDEV-26326 MDEV-24626 (remove synchronous page0 ... Closed
relates to MDEV-26631 Race condition in the test innodb.dou... Closed
relates to MDEV-28870 InnoDB: Missing FILE_CREATE, FILE_DEL... Closed
relates to MDEV-29987 Bogus errors about file size in the t... Closed
relates to MDEV-30132 Crash after recovery, with InnoDB: Tr... Closed
relates to MDEV-32939 If tables are frequently created, ren... Closed
relates to MDEV-18200 MariaBackup full backup failed with I... Closed
relates to MDEV-25656 Atomic DDL: Assertion `!full_crc32(fl... Closed
relates to MDEV-25657 Atomic DDL: InnoDB: Cannot apply log,... Closed
relates to MDEV-26001 InnoDB: Cannot apply log to [page id:... Closed

 Description   

InnoDB holds dict_sys mutex while doing file i/o operation during creation of table.
In fil_ibd_create():

        if (ulint zip_size = fil_space_t::zip_size(flags)) {
                page_zip_des_t  page_zip;
                page_zip_set_size(&page_zip, zip_size);
                page_zip.data = page + srv_page_size;
#ifdef UNIV_DEBUG
                page_zip.m_start = 0;
#endif /* UNIV_DEBUG */
                page_zip.m_end = 0;
                page_zip.m_nonempty = 0;
                page_zip.n_blobs = 0;
 
                buf_flush_init_for_writing(NULL, page, &page_zip, false);
 
                *err = os_file_write(IORequestWrite, path, file,
                                     page_zip.data, 0, zip_size);
        } else {
                buf_flush_init_for_writing(NULL, page, NULL,
                                           fil_space_t::full_crc32(flags));
 
                *err = os_file_write(IORequestWrite, path, file,
                                     page, 0, srv_page_size);
        }
 
        if (!os_file_flush(file)) {
                ib::error() << "File flush of tablespace '"
                        << path << "' failed";
                *err = DB_ERROR;
                goto err_exit;
        }

If we remove the page0 write and flushing the file then InnoDB should handle this scenario during recovery. Right now, InnoDB does the validation of page0 while parsing the FILE redo log records.

InnoDB should defer these tablespace as uninitialized if it encounters zero-filled page 0
and recover page0 of these tablespace before recovering any other pages of these tablespace. This is the idea right now. It could change when we're debuggging encrypted and compressed tablespace.



 Comments   
Comment by Marko Mäkelä [ 2021-03-19 ]

Some more changes are needed in mariabackup.

Comment by Marko Mäkelä [ 2021-04-07 ]

As far as I understand, there still are some recovery or backup failures that are related to this change.

Comment by Thirunarayanan Balathandayuthapani [ 2021-04-20 ]

Updated patch is in bb-10.6-MDEV-24626_1

Comment by Marko Mäkelä [ 2021-05-11 ]

The test innodb_fts,crash_recovery that was extended in MDEV-18518 revealed that this fix is not only a performance improvement but also a correctness fix, to make all DDL inside InnoDB truly crash-safe. The report MDEV-25646 basically duplicates what I have already seen in innodb_fts,crash_recovery,release. I enhanced Thiru’s work this week, so that it would survive all my mtr tests.

Comment by Marko Mäkelä [ 2021-07-21 ]

Some unnecessary code was not removed until 10.6.4.

Generated at Thu Feb 08 09:31:25 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.