add 3.4 tests

Signed-off-by: Alex Chi <iskyzh@gmail.com>
This commit is contained in:
Alex Chi
2024-01-30 12:14:32 +08:00
parent 6723ba07fd
commit 4ad97f716c
8 changed files with 240 additions and 33 deletions

View File

@@ -144,7 +144,7 @@ impl LsmStorageInner {
continue;
}
if same_as_last_key && iter.key().ts() < watermark {
if same_as_last_key && iter.key().ts() <= watermark {
if !first_key_below_watermark {
iter.next()?;
continue;
@@ -155,7 +155,7 @@ impl LsmStorageInner {
let builder_inner = builder.as_mut().unwrap();
if builder_inner.estimated_size() >= self.options.target_sst_size && !same_as_last_key {
let sst_id: usize = self.next_sst_id();
let sst_id = self.next_sst_id();
let old_builder = builder.take().unwrap();
let sst = Arc::new(old_builder.build(
sst_id,
@@ -300,22 +300,22 @@ impl LsmStorageInner {
println!("force full compaction: {:?}", compaction_task);
let sstables = self.compact(&compaction_task)?;
let mut ids = Vec::with_capacity(sstables.len());
{
let _state_lock = self.state_lock.lock();
let state_lock = self.state_lock.lock();
let mut state = self.state.read().as_ref().clone();
for sst in l0_sstables.iter().chain(l1_sstables.iter()) {
let result = state.sstables.remove(sst);
assert!(result.is_some());
}
let mut ids = Vec::with_capacity(sstables.len());
for new_sst in sstables {
ids.push(new_sst.sst_id());
let result = state.sstables.insert(new_sst.sst_id(), new_sst);
assert!(result.is_none());
}
assert_eq!(l1_sstables, state.levels[0].1);
state.levels[0].1 = ids;
state.levels[0].1 = ids.clone();
let mut l0_sstables_map = l0_sstables.iter().copied().collect::<HashSet<_>>();
state.l0_sstables = state
.l0_sstables
@@ -325,12 +325,17 @@ impl LsmStorageInner {
.collect::<Vec<_>>();
assert!(l0_sstables_map.is_empty());
*self.state.write() = Arc::new(state);
self.sync_dir()?;
self.manifest.as_ref().unwrap().add_record(
&state_lock,
ManifestRecord::Compaction(compaction_task, ids.clone()),
)?;
}
for sst in l0_sstables.iter().chain(l1_sstables.iter()) {
std::fs::remove_file(self.path_of_sst(*sst))?;
}
println!("force full compaction done");
println!("force full compaction done, new SSTs: {:?}", ids);
Ok(())
}