fix: avoid leveled compaction crash when recovering from manifest (#63)
* Fix: Avoid leveled copaction crash when recovering from manifest * Also sort SSTs in manifest recovery * Add `in_recovery` flag to `apply_compaction_result` - Don't sort the SSTs inside `apply_compaction_result` if in recovery
This commit is contained in:
@@ -368,8 +368,8 @@ impl LsmStorageInner {
|
||||
memtables.insert(x);
|
||||
}
|
||||
ManifestRecord::Compaction(task, output) => {
|
||||
let (new_state, _) =
|
||||
compaction_controller.apply_compaction_result(&state, &task, &output);
|
||||
let (new_state, _) = compaction_controller
|
||||
.apply_compaction_result(&state, &task, &output, true);
|
||||
// TODO: apply remove again
|
||||
state = new_state;
|
||||
next_sst_id =
|
||||
@@ -400,6 +400,18 @@ impl LsmStorageInner {
|
||||
|
||||
next_sst_id += 1;
|
||||
|
||||
// Sort SSTs on each level
|
||||
for (_id, ssts) in &mut state.levels {
|
||||
ssts.sort_by(|x, y| {
|
||||
state
|
||||
.sstables
|
||||
.get(x)
|
||||
.unwrap()
|
||||
.first_key()
|
||||
.cmp(state.sstables.get(y).unwrap().first_key())
|
||||
})
|
||||
}
|
||||
|
||||
// recover memtables
|
||||
if options.enable_wal {
|
||||
let mut wal_cnt = 0;
|
||||
|
||||
Reference in New Issue
Block a user