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:
@@ -561,8 +561,12 @@ fn main() {
|
||||
.join(", ")
|
||||
);
|
||||
max_space = max_space.max(storage.file_list.len());
|
||||
let (snapshot, del) =
|
||||
controller.apply_compaction_result(&storage.snapshot, &task, &sst_ids);
|
||||
let (snapshot, del) = controller.apply_compaction_result(
|
||||
&storage.snapshot,
|
||||
&task,
|
||||
&sst_ids,
|
||||
false,
|
||||
);
|
||||
storage.snapshot = snapshot;
|
||||
storage.remove(&del);
|
||||
println!("--- After Compaction ---");
|
||||
|
@@ -68,10 +68,11 @@ impl CompactionController {
|
||||
snapshot: &LsmStorageState,
|
||||
task: &CompactionTask,
|
||||
output: &[usize],
|
||||
in_recovery: bool,
|
||||
) -> (LsmStorageState, Vec<usize>) {
|
||||
match (self, task) {
|
||||
(CompactionController::Leveled(ctrl), CompactionTask::Leveled(task)) => {
|
||||
ctrl.apply_compaction_result(snapshot, task, output)
|
||||
ctrl.apply_compaction_result(snapshot, task, output, in_recovery)
|
||||
}
|
||||
(CompactionController::Simple(ctrl), CompactionTask::Simple(task)) => {
|
||||
ctrl.apply_compaction_result(snapshot, task, output)
|
||||
|
@@ -50,6 +50,7 @@ impl LeveledCompactionController {
|
||||
_snapshot: &LsmStorageState,
|
||||
_task: &LeveledCompactionTask,
|
||||
_output: &[usize],
|
||||
_in_recovery: bool,
|
||||
) -> (LsmStorageState, Vec<usize>) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
Reference in New Issue
Block a user