https://slatedb.io logo
Hey everyone, I was reading the compaction design ...
# general
b
Hey everyone, I was reading the compaction design document to kick off this issue on validating compactions submitted to the orchestrator, but I still have doubts about which validations are expected. From reading the document the validations that I think we could add are: Schedule a compaction for L0 if: * The number of SRs in L0 > l0_compaction_threshold_ssts * The number of SRs in L1 < compaction.scheduler.tiered.level_max_runs * The number of uncompleted compactions < max_compactions * No ongoing compaction from L0 From what I saw on the maybe_schedule_compaction function the only validation applied there is the number of ssts in l0 must be greater or equal to 4 to schedule a compaction. If the issue is aiming to validate something different please let me know., more than happy to follow it and learn. https://github.com/slatedb/slatedb/issues/96
c
👋 hey Brayan. I’ll try and get back to you tomorrow unless @Rohan beats me to it.
r
thanks for the question @brayanjules ! I think you may be conflating two things: 1. deciding what compactions to schedule. This is decided by the compaction scheduler. Currently the scheduler is very dumb and only schedules l0 compactions, but we'll make it more sophisticated over time (I'm actually working on something in this area now to have it compact similarly sized sorted runs). 2. making sure that the scheduled compactions don't cause the db to enter an incorrect state where we could serve the wrong data at read time. In theory the scheduler should never schedule a "bad" compaction, but we should have the orchestrator check that and reject any compactions that leave the db in a bad state that could cause data inconsistencies. This is what the issue #96 is meant to cover. The compaction design doc goes over what constitutes a "valid" vs an invalid compaction in the section on compactions under "Compacting lower levels": https://github.com/slatedb/slatedb/blob/main/docs/0002-compaction.md#compactions
IMO the right place to do this validation is from the
submit_compaction
method in
compactor_state.rs
. This way we ensure that we can never cause a bad compaction to ever get executed: https://github.com/slatedb/slatedb/blob/275ebf7804a6f53d604251a2576bc7a56b491110/src/compactor_state.rs#L89
b
Thanks, I read about the second point in the document but thought it was something that should be done in the executor, but now I get it. I would come up with a draft PR.