Sujeet
08/13/2025, 8:01 AMalmog
08/13/2025, 4:53 PMcriccomini
08/13/2025, 5:08 PMSujeet
08/13/2025, 5:57 PMRohan
08/13/2025, 7:00 PMSujeet
08/14/2025, 2:15 PMrust
async fn submit_compaction(&mut self, compaction: Compaction) -> Result<(), SlateDBError> {
let id = self.rand.rng().gen_uuid();
tracing::Span::current().record("id", tracing::field::display(&id));
// Compaction validation
let result = self.state.submit_compaction(id, compaction.clone());
// Persist compaction here
match result {
Ok(_) => {
self.start_compaction(id, compaction).await?;
}
Err(err) => {
warn!("invalid compaction: {:?}", err);
}
}
Ok(())
}
However, I think we should the active running compaction check should happen before starting the compaction.
rust
async fn maybe_schedule_compactions(&mut self) -> Result<(), SlateDBError> {
let compactions = self.scheduler.maybe_schedule_compaction(&self.state);
for compaction in compactions.iter() {
if self.state.num_compactions() >= self.options.max_concurrent_compactions {
info!(
"already running {} compactions, which is at the max {}. Won't run compaction {:?}",
self.state.num_compactions(),
self.options.max_concurrent_compactions,
compaction
);
break;
}
self.submit_compaction(compaction.clone()).await?;
}
Ok(())
}Rohan
08/14/2025, 4:58 PMSujeet
08/14/2025, 5:22 PMstart_compaction(id, compaction)
What if the compaction scheduled exceeds the threshold of active compactions? Should we persist it or drop it?Rohan
08/14/2025, 6:06 PMcriccomini
08/15/2025, 1:18 AMSujeet
08/15/2025, 1:27 AMsubmit_compaction() method in the Compaction Event Handler. EXternal requests would be validated using the same ConflictChecker and compaction state validations before persisting.criccomini
08/15/2025, 1:30 AMcriccomini
08/15/2025, 1:30 AMSujeet
08/15/2025, 2:04 AMcriccomini
08/15/2025, 3:03 AMSujeet
08/15/2025, 4:32 AMsubmit_external_compaction() with the CompactionRequest that would have parameters like source L0 SSTs and source SRs.
submit_external_compaction() validates the request and transforms it into a Compaction struct object. This object is then passed to a channel that is listened by the eventLoop.
EventLoop would take care of persisting the request.Sujeet
08/15/2025, 4:35 AMSujeet
08/15/2025, 9:26 AMcriccomini
08/15/2025, 5:22 PMcriccomini
08/15/2025, 5:34 PMnew_compactions object to Step(3).
What if the step(3) execution discovers that there are invalid commpactions? Are they dropped?
> - Writes the updated compacted_state to a blocking channel that would be listened and executed by the Compaction Event Handler.
+1 for this approach
> ### Persisting External Compactions
This section seems to depend on sending external compaction requests through an in-memory channel. We want to support triggering compactions from the CLI, though, which will likely be running on a separate machine. I don't see how that can work if we depend on in-memory channels to pass external requests. Are you suggesting the CLI spin up a Db instance itself to write the compaction request? That would fence both the writer and compactor processes.Sujeet
08/15/2025, 5:42 PMnew_compactions list would be dropped.Sujeet
08/15/2025, 5:49 PMcriccomini
08/15/2025, 5:50 PMcriccomini
08/15/2025, 5:51 PMSujeet
08/15/2025, 5:51 PMcriccomini
08/15/2025, 5:51 PMcriccomini
08/15/2025, 5:54 PMcriccomini
08/15/2025, 5:54 PMSujeet
08/15/2025, 5:54 PMrust
// API method signature uses the public struct directly
pub async fn submit_manual_compaction(
&self,
source_ssts: Vec<String>,
source_srs: Vec<String>
) -> Result<CompactionInfo, Error>
The submit_manual_compaction would look something like this. Any client(reader, writer, compactor) invokes this method. The validations would be made within this method and after sucessful validation it would write to the .compactor file active_compactions.criccomini
08/15/2025, 5:54 PMcriccomini
08/15/2025, 5:54 PMcriccomini
08/15/2025, 5:55 PMcriccomini
08/15/2025, 5:55 PMadmin.rs instantiate what it needs directly rather than creating a full Db.Sujeet
08/15/2025, 5:55 PMcriccomini
08/15/2025, 5:56 PMcriccomini
08/15/2025, 5:56 PMSujeet
08/15/2025, 5:56 PMcriccomini
08/15/2025, 5:57 PMcriccomini
08/15/2025, 5:57 PMcriccomini
08/15/2025, 5:57 PMSujeet
08/15/2025, 6:00 PMcriccomini
08/15/2025, 6:01 PMcriccomini
08/15/2025, 6:01 PMSujeet
08/15/2025, 6:02 PMcriccomini
08/15/2025, 6:02 PMSujeet
08/15/2025, 6:04 PMcriccomini
08/15/2025, 6:05 PMSujeet
08/15/2025, 6:06 PMcriccomini
08/15/2025, 6:08 PMcriccomini
08/15/2025, 6:10 PMcriccomini
08/15/2025, 6:10 PMSujeet
08/15/2025, 6:13 PMcriccomini
08/15/2025, 6:13 PMcriccomini
08/15/2025, 6:13 PMSujeet
08/15/2025, 6:14 PMcriccomini
08/15/2025, 6:14 PMcriccomini
08/15/2025, 6:16 PMalmog
08/15/2025, 6:17 PM.compactor file by spinning up a non-fencing instance of the DB and calling the same methods that request a compaction from the compaction loop? that's pretty clean, I assume we'll have the compactor loop request compactions this way as well to keep it consistent?criccomini
08/15/2025, 6:17 PMcriccomini
08/15/2025, 6:18 PMSujeet
08/15/2025, 6:20 PMcriccomini
08/15/2025, 6:20 PMSujeet
08/15/2025, 6:23 PMcriccomini
08/15/2025, 6:24 PMcriccomini
08/15/2025, 6:24 PMSujeet
08/15/2025, 6:25 PMSujeet
08/15/2025, 6:33 PMrust
impl Ord for MergeIteratorHeapEntry<'_> {
fn cmp(&self, other: &Self) -> Ordering {
// we'll wrap a Reverse in the BinaryHeap, so the cmp here is in increasing order.
// after Reverse is wrapped, it will return the entries with higher seqnum first.
(&self.next_kv.key, self.next_kv.seq).cmp(&(&other.next_kv.key, other.next_kv.seq))
}
}
I think it return higher seqNum first for a given key.criccomini
08/15/2025, 6:33 PMcriccomini
08/15/2025, 6:34 PMSujeet
08/15/2025, 6:38 PMrust
async fn load_manifest(&mut self) -> Result<(), SlateDBError> {
self.manifest.refresh().await?;
self.refresh_db_state().await?;
Ok(())
}
async fn refresh_db_state(&mut self) -> Result<(), SlateDBError> {
self.state
.merge_remote_manifest(self.manifest.prepare_dirty()?);
self.maybe_schedule_compactions().await?;
Ok(())
}
With reference to the earlier conversation on having a separate poller, The manifest poller refreshes the db_state that triggers a call to check if compactions need to be scheduled. So, I think we might not need a new poller.criccomini
08/15/2025, 6:40 PMcriccomini
08/15/2025, 6:40 PMRohan
08/15/2025, 8:55 PMRohan
08/15/2025, 8:56 PMRohan
08/15/2025, 9:01 PMcriccomini
08/15/2025, 9:03 PMcriccomini
08/15/2025, 9:04 PMcriccomini
08/15/2025, 9:05 PMcriccomini
08/15/2025, 9:05 PMcriccomini
08/15/2025, 9:05 PMRohan
08/15/2025, 9:06 PMRohan
08/15/2025, 9:06 PMcriccomini
08/15/2025, 9:06 PMcriccomini
08/15/2025, 9:07 PMRohan
08/15/2025, 9:07 PMcriccomini
08/15/2025, 9:07 PMRohan
08/15/2025, 9:07 PMcriccomini
08/15/2025, 9:07 PMcriccomini
08/15/2025, 9:07 PMRohan
08/15/2025, 9:07 PMcriccomini
08/15/2025, 9:08 PMRohan
08/15/2025, 9:08 PMcriccomini
08/15/2025, 9:08 PMcriccomini
08/15/2025, 9:09 PMcriccomini
08/15/2025, 9:09 PMcriccomini
08/15/2025, 9:09 PMcriccomini
08/15/2025, 9:09 PMRohan
08/15/2025, 9:13 PMRohan
08/15/2025, 9:14 PMcriccomini
08/15/2025, 9:14 PMRohan
08/15/2025, 9:31 PMcriccomini
08/15/2025, 9:31 PMcriccomini
08/15/2025, 9:31 PMRohan
08/15/2025, 9:33 PMcriccomini
08/15/2025, 9:33 PMSujeet
08/16/2025, 3:59 AMrefresh_db_state method. Then, do we need a separate poller?Sujeet
08/16/2025, 4:18 AMcriccomini
08/16/2025, 11:30 PMcriccomini
08/16/2025, 11:31 PMSujeet
08/17/2025, 4:01 AMSujeet
08/22/2025, 1:47 AMcriccomini
08/22/2025, 4:05 AMRohan
08/22/2025, 5:18 AMSujeet
08/22/2025, 6:00 AM