From 05d6e4bd9db1725382719ee518c8d2ea7973ff5c Mon Sep 17 00:00:00 2001 From: ad hoc Date: Wed, 18 Sep 2024 16:06:51 +0200 Subject: [PATCH] fix compactor shortest path when there are no segments --- libsql-wal/src/storage/compaction/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libsql-wal/src/storage/compaction/mod.rs b/libsql-wal/src/storage/compaction/mod.rs index 01a66a1516..d91cf27238 100644 --- a/libsql-wal/src/storage/compaction/mod.rs +++ b/libsql-wal/src/storage/compaction/mod.rs @@ -403,6 +403,13 @@ pub struct AnalyzedSegments { impl AnalyzedSegments { /// returns a list of keys that covers frame_no 1 to last in the shortest amount of segments pub fn shortest_restore_path(&self) -> SegmentSet { + if self.graph.node_count() == 0 { + return SegmentSet { + namespace: self.namespace.clone(), + segments: Vec::new(), + }; + } + let path = petgraph::algo::astar( &self.graph, 1,