Skip to content

Commit

Permalink
fix: blocking at cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Jul 30, 2024
1 parent 7c9a926 commit 023eb80
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/compaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ where
let mut guard = self.schema.write().await;

if guard.mutable.is_empty() {
println!("WWWWWW");
return Ok(())
}
let mutable = mem::replace(&mut guard.mutable, Mutable::new(&self.option).await?);
Expand Down
18 changes: 9 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ pub(crate) mod tests {
]
}

#[tokio::test]
#[tokio::test(flavor = "multi_thread")]
async fn read_from_disk() {
let temp_dir = TempDir::new().unwrap();

Expand All @@ -954,14 +954,14 @@ pub(crate) mod tests {
db.write(item, 0.into()).await.unwrap();
}

// let tx = db.transaction().await;
// let key = 20.to_string();
// let option1 = tx.get(&key, Projection::All).await.unwrap().unwrap();
//
// assert_eq!(option1.get().map(|test_ref| test_ref.vstring), Some("20"));
// assert_eq!(option1.get().map(|test_ref| test_ref.vu32), Some(Some(0)));
// assert_eq!(option1.get().map(|test_ref| test_ref.vbool), Some(Some(true)));
let tx = db.transaction().await;
let key = 20.to_string();
let option1 = tx.get(&key, Projection::All).await.unwrap().unwrap();

// dbg!(db.version_set.current().await);
assert_eq!(option1.get().map(|test_ref| test_ref.vstring), Some("20"));
assert_eq!(option1.get().map(|test_ref| test_ref.vu32), Some(Some(0)));
assert_eq!(option1.get().map(|test_ref| test_ref.vbool), Some(Some(true)));

dbg!(db.version_set.current().await);
}
}
8 changes: 4 additions & 4 deletions src/version/cleaner.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{collections::BTreeMap, fs, io, sync::Arc};
use std::{collections::BTreeMap, io, sync::Arc};

use flume::{Receiver, Sender};

use tokio::fs;
use crate::{fs::FileId, timestamp::Timestamp, DbOption};

pub enum CleanTag {
Expand Down Expand Up @@ -42,10 +42,10 @@ impl Cleaner {
while let Some((first_version, (gens, dropped))) = self.gens_map.pop_first() {
if !dropped {
let _ = self.gens_map.insert(first_version, (gens, false));
continue;
break;
}
for gen in gens {
fs::remove_file(self.option.table_path(&gen))?;
fs::remove_file(self.option.table_path(&gen)).await?;
}
}
}
Expand Down

0 comments on commit 023eb80

Please sign in to comment.