fix wal close not waiting for threads, better test harness

Signed-off-by: Alex Chi <iskyzh@gmail.com>
This commit is contained in:
Alex Chi
2024-01-28 16:38:56 +08:00
parent 9b75e72e58
commit 85acf69dcc
4 changed files with 17 additions and 16 deletions

View File

@@ -188,12 +188,6 @@ impl MiniLsm {
self.compaction_notifier.send(()).ok();
self.flush_notifier.send(()).ok();
if self.inner.options.enable_wal {
self.inner.sync()?;
self.inner.sync_dir()?;
return Ok(());
}
let mut compaction_thread = self.compaction_thread.lock();
if let Some(compaction_thread) = compaction_thread.take() {
compaction_thread
@@ -207,6 +201,12 @@ impl MiniLsm {
.map_err(|e| anyhow::anyhow!("{:?}", e))?;
}
if self.inner.options.enable_wal {
self.inner.sync()?;
self.inner.sync_dir()?;
return Ok(());
}
// create memtable and skip updating manifest
if !self.inner.state.read().memtable.is_empty() {
self.inner

View File

@@ -401,12 +401,13 @@ pub fn check_compaction_ratio(storage: Arc<MiniLsm>) {
}
pub fn dump_files_in_dir(path: impl AsRef<Path>) {
println!("--- DIR DUMP ---");
for f in path.as_ref().read_dir().unwrap() {
let f = f.unwrap();
print!("{}", f.path().display());
println!(
"{}, size={:.3}KB",
f.path().display(),
", size={:.3}KB",
f.metadata().unwrap().size() as f64 / 1024.0
)
);
}
}