tikv / rocksdb

A library that provides an embeddable, persistent key-value store for fast storage.
http://rocksdb.org
GNU General Public License v2.0
119 stars 92 forks source link

Ensure writes to WAL tail during `FlushWAL(true /* sync */)` will be … #357

Closed Connor1996 closed 5 months ago

Connor1996 commented 5 months ago

…synced (#10560)

Summary: WAL append and switch can both happen between FlushWAL(true /* sync */)'s sync operations and its call to MarkLogsSynced(). We permit this since locks need to be released for the sync operations. Such an appended/switched WAL is both inactive and incompletely synced at the time MarkLogsSynced() processes it.

Prior to this PR, MarkLogsSynced() assumed all inactive WALs were fully synced and removed them from consideration for future syncs. That was wrong in the scenario described above and led to the latest append(s) never being synced. This PR changes MarkLogsSynced() to only remove inactive WALs from consideration for which all flushed data has been synced.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10560

Test Plan: repro unit test for the scenario described above. Without this PR, it fails on "key2" not found

Reviewed By: riversand963

Differential Revision: D38957391

Pulled By: ajkr

fbshipit-source-id: da77175eba97ff251a4219b227b3bb2d4843ed26