• M
    [wal changes 2/3] write with sync=true syncs previous unsynced wals to prevent illegal data loss · fe09a6da
    Mike Kolupaev 提交于
    Summary:
    I'll just copy internal task summary here:
    
    "
    This sequence will cause data loss in the middle after an sync write:
    
    non-sync write key 1
    flush triggered, not yet scheduled
    sync write key 2
    system crash
    
    After rebooting, users might see key 2 but not key 1, which violates the API of sync write.
    
    This can be reproduced using unit test FaultInjectionTest::DISABLED_WriteOptionSyncTest.
    
    One way to fix it is for a sync write, if there is outstanding unsynced log files, we need to syc them too.
    "
    
    This diff should be considered together with the next diff D40905; in isolation this fix probably could be a little simpler.
    
    Test Plan: `make check`; added a test for that (DBTest.SyncingPreviousLogs) before noticing FaultInjectionTest.WriteOptionSyncTest (keeping both since mine asserts a bit more); both tests fail without this diff; for D40905 stacked on top of this diff, ran tests with ASAN, TSAN and valgrind
    
    Reviewers: rven, yhchiang, IslamAbdelRahman, anthony, kradhakrishnan, igor, sdong
    
    Reviewed By: sdong
    
    Subscribers: dhruba
    
    Differential Revision: https://reviews.facebook.net/D40899
    fe09a6da
db_impl.cc 158.2 KB