• Marko Mäkelä's avatar
    MDEV-19738: Doublewrite buffer is unnecessarily used for newly (re)initialized pages · 8bb4ea2e
    Marko Mäkelä authored
    Thanks to MDEV-12699, the doublewrite buffer will only be needed in
    those cases when a page is being updated in the data file. If the page
    had never been written to the data file since it was initialized,
    then recovery will be able to reconstruct the page based solely on
    the contents of the redo log files.
    
    The doublewrite buffer is only really needed when recovery needs to read
    the page in order to apply redo log.
    
    Note: As noted in MDEV-19739, we cannot safely disable the doublewrite
    buffer if any MLOG_INDEX_LOAD records were written in the past or will
    be written in the future. These records denote that redo logging was
    disabled for some pages in a tablespace. Ideally, we would have
    the setting innodb_log_optimize_ddl=OFF by default, and would not allow
    it to be set while the server is running. If we wanted to make this
    safe, assignments with SET GLOBAL innodb_log_optimize_ddl=...
    should not only issue a redo log checkpoint (including a write of all
    dirty pages from the entire buffer pool), but it should also wait for
    all pending ALTER TABLE activity to complete. We elect not to do this.
    
    Avoiding unnecessary use of the doublewrite buffer should improve the
    write performance of InnoDB.
    
    buf_page_t::init_on_flush: A new flag to indicate whether it is safe to
    skip doublewrite buffering when writing the page.
    
    fsp_init_file_page(): When writing a MLOG_INIT_FILE_PAGE2 record,
    set the init_on_flush flag if innodb_log_optimize_ddl=OFF.
    This is the only function that writes that log record.
    
    buf_flush_write_block_low(): Skip doublewrite if init_on_flush is set.
    
    fil_aio_wait(): Clear init_on_flush.
    8bb4ea2e
btr0bulk.h 8.8 KB