• Arun Kuruvila's avatar
    Bug #26880757: MYISAM_USE_MMAP=1 ON WINDOWS FREQUENTLY DOES · bd1fe261
    Arun Kuruvila authored
                   NOT UPDATE FILE ON DISK
    
    Description:- When the server variable, "myisam_use_mmap" is
    enabled, MyISAM tables on windows are not updating the file
    on disk even when the server variable "flush" is set to 1.
    This is inturn making the table corrupted when encountering
    a power failure.
    
    Analysis:- When the server variable "myisam_use_mmap" is set,
    files of MyISAM tables will be memory mapped using the OS
    APIs mmap()/munmap()/msync() on Unix and CreateFileMapping()
    /UnmapViewOfFile()/FlushViewOfFile() on Windows. msync() and
    FlushViewOfFile() is responsible for flushing the changes
    made to the in-core copy of a file that was mapped into
    memory using mmap()/CreateFileMapping() back to the
    file system.  FLUSH is determined by the OS unless
    explicitly called using msync()/FlushViewOfFile().
    
    When the server variables "myisam_use_mmap" and "flush" are
    enabled, MyISAM is only flushing the files from file system
    cache to disc using "mysql_file_sync()" and not the memory
    mapped file from memory to FS cache using "my_msync()".
    ["my_msync()" inturn calls  msync() on Unix and
    FlushViewOfFile() on Windows.
    
    Fix:- As part of the fix, if server variable
    "myisam_use_mmap" is enabled along with  "flush",
    "my_msync()" is invoked to flush the data in memory to file
    system cache and followed by "mysql_file_sync()" which will
    flush the data from file system cache to disk.
    bd1fe261
mi_locking.c 17 KB