Sujeet
08/10/2025, 12:30 PMSujeet
08/10/2025, 1:21 PMtext
#### On startup...
1. Compactor fetches the latest .manifest file (00005.manifest).
2. Compactor now fetches the latest .compactor file (00005.compactor).
3. It builds a dirty compactionState by merging L0 SSTs and SortedRuns across both files.
- Copy SortedRuns from .compactor file to compactionState
- Add and delete L0 SSTs of .manifest in compactionState
4. Compactor increments `compactor_epoch` in the dirty CompactionState and writes the dirty CompactionState to the next sequential .compactor position.(00006.compactor). Two level validation:
Epoch Check fails, compactor is fenced
File version check (in-memory and remote object store), If 00006.compactor exists,
- If latest .compactor compactor_epoch > current compactor's epoch, die (fenced)
- If latest .compactor compactor_epoch == current compactor's epoch, die (fenced)
If latest .compactor compactor_epoch == current compactor's epoch, we would need to think how we handle this case in the external compaction request scenario.Sujeet
08/13/2025, 8:04 AMalmog
08/13/2025, 4:40 PM.compactor that is append-only for external writers and on conflict they retry. A compactor that owns the epoch lock can remove from the requested.
We would need to change the protocol for seeing new .compactor files with epochs we've already seen (see below)
Example:
compactor.0001 {
c_epoch: 10,
requested: [request1]
}
A. Clean Path
External 1: read compactor.0001
External 1: writes compactor.0002 {requested = [request1, request2]}
B. External Race
External 1: read compactor.0001
External 2: read compactor.0001
External 2: writes compactor.0002 {requested = [request1, request2]}
External 2: attempt write compactor.0002 | exists => fenced
External 2: writes compactor.0003 {requested = [request1, request2, request3]}
C. Compactor Race (External Wins)
External: read compactor.0001
Compactor: read compactor.0001
External: writes compactor.0002 {requested = [request1, request2]}
Compactor: writes compactor.002 | CONFLICT
Compactor: attempt epoch bump protocol on new .compactor file with same epoch, write compactor.003 with new epoch
D. Compactor Race (Compactor Wins)
External: read compactor.0001
Compactor: read compactor.0001
Compactor: writes compactor.002
External: writes compactor.002 | CONFLICT FAIL
External: writes compactor.003 {requested = [request1]} SUCCESSSujeet
08/13/2025, 5:10 PMactive_compaction list persisted that would hold compactions that were being executed and would be moved to the manifest compacted SRs.
text
table CompactionState {
// Identifier of the compaction state. Compactor file name would be derived from this field
compaction_state_id: uint64;
// Fencing token to ensure single active compactor
compactor_epoch: uint64;
// Compactions in scheduled, in_progress and recently completed compactions
active_compactions: [Compaction];
// Creation Timestamp of CompactionState
created_at: uint64
}
Would the request_id be same as the compactor_id or something that the client would provide? Also, would you return the request_id once it is persisted or as soon as the compaction struct is created?criccomini
08/13/2025, 5:25 PMcriccomini
08/13/2025, 5:31 PMactive_compactions as well? I can't recall how many fields Compaction has, or which specifc fields a request needs.almog
08/13/2025, 5:40 PMactive_compactions is the active compactor. Now that I'm thinking about it I'd be tempted to even have a requested compaction dir that's totally separate and append only entirely (doesn't modify the compactor file at all)criccomini
08/13/2025, 5:46 PMCompaction, then that makes sense. To me, a request is just a scheduled compaction, though. (we would just need the compactor to verify it doesn't conflict before executing it.) OTOH, I saw that @Sujeet had added a lot of fields like priority and stuff... if that's the case, then keeping separate makes sense.criccomini
08/13/2025, 5:47 PMSujeet
08/13/2025, 5:56 PMcompaction struct based on the request parameters and persist it as part of the active_compaction with no job_attempts(similar to how I was planning to update the existing compaction workflow).
As a result, we would not need a separate handling of these external requests and can be accomodated in the existing compaction workflow.
I had added a few more CompactionStatus states and CompactionType. I think we can drop off CompactionPriority to start with.criccomini
08/13/2025, 5:58 PMcriccomini
08/13/2025, 5:58 PMalmog
08/13/2025, 5:59 PMcriccomini
08/13/2025, 6:00 PMcriccomini
08/13/2025, 6:00 PMalmog
08/13/2025, 6:02 PMSujeet
08/13/2025, 6:03 PMSujeet
08/14/2025, 8:59 AMactive_compaction list/map. Currently, we only submit_compaction if the threshold is not breached.
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(())
}Sujeet
08/14/2025, 9:08 AMSujeet
08/14/2025, 9:33 AMRohan
08/14/2025, 4:55 PMConflictChecker is just an implementation detail of the size-tiered scheduler. It skips over compactions that migth conflict and moves on to other compactions. submit_compaction is the final decider of what compactions actually execute. We could probably change size-tiered scheduler to just return a list of all possible compactions and have the event handler skip over ones that conflict. Not sure its worth doingRohan
08/14/2025, 5:00 PMSujeet
08/15/2025, 2:30 AMConflictChecker and submit_compaction would be requried.
Wdyt?criccomini
08/15/2025, 3:05 AMcriccomini
08/15/2025, 3:08 AMSujeet
08/15/2025, 4:29 AM