Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

a qustion about the order of write wal and write manifest #124

Open
baobaomaomeng opened this issue Feb 17, 2025 · 0 comments
Open

a qustion about the order of write wal and write manifest #124

baobaomaomeng opened this issue Feb 17, 2025 · 0 comments

Comments

@baobaomaomeng
Copy link

Consider the following code(in min-lsm/src/lsm_storage line714-line725):

if self.options.enable_wal {
    std::fs::remove_file(self.path_of_wal(sst_id))?;
}
self.manifest
    .as_ref()
    .unwrap()
    .add_record(&state_lock, ManifestRecord::Flush(sst_id))?;

self.sync_dir()?;

If the program loses power after the WAL deletion is completed, an error will occur during recovery, and we will be unable to restore the flushed memtable(which is not flush in record).
Therefore, in theory, we should reverse the order of these two.

However, I still have a concern regarding the reordering of code and instructions by the compiler and CPU. The write operation to the WAL (Write - Ahead Log) and the write operation to the manifest do not establish a happen - before relationship. In theory, their execution order can be swapped. If this happens, we may encounter the problem described in the above - mentioned code once again.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant