Backport "compaction: Fix incremental compaction for sstable cleanup" to branch-5.1 #14195
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After c7826aa, sstable runs are cleaned up together.
The procedure which executes cleanup was holding reference to all input sstables, such that it could later retry the same cleanup job on failure.
Turns out it was not taking into account that incremental compaction will exhaust the input set incrementally.
Therefore cleanup is affected by the 100% space overhead.
To fix it, cleanup will now have the input set updated, by removing the sstables that were already cleaned up. On failure, cleanup will retry the same job with the remaining sstables that weren't exhausted by incremental compaction.
New unit test reproduces the failure, and passes with the fix.
Fixes #14035.
Closes #14038
(cherry picked from commit 23443e0)