• Marko Mäkelä's avatar
    MDEV-18349 InnoDB file size changes are not safe when file system crashes · 31d592ba
    Marko Mäkelä authored
    When InnoDB is invoking posix_fallocate() to extend data files, it
    was missing a call to fsync() to update the file system metadata.
    If file system recovery is needed, the file size could be incorrect.
    
    When the setting innodb_flush_method=O_DIRECT_NO_FSYNC
    that was introduced in MariaDB 10.0.11 (and MySQL 5.6) is enabled,
    InnoDB would wrongly skip fsync() after extending files.
    
    Furthermore, the merge commit d8b45b0c
    inadvertently removed XtraDB error checking for posix_fallocate()
    which this fix is restoring.
    
    fil_flush(): Add the parameter bool metadata=false to request that
    fil_buffering_disabled() be ignored.
    
    fil_extend_space_to_desired_size(): Invoke fil_flush() with the
    extra parameter. After successful posix_fallocate(), invoke
    os_file_flush(). Note: The bookkeeping for fil_flush() would not be
    updated the posix_fallocate() code path, so the "redundant"
    fil_flush() should be a no-op.
    31d592ba
fil0fil.cc 172 KB