Skip to content

Conversation

@ywave620
Copy link
Contributor

@ywave620 ywave620 commented Nov 8, 2025

Summary:
Fix a bug where CompactRange with BottommostLevelCompaction::kForceOptimized would incorrectly return early when two conditions occurred simultaneously:

  1. max_compaction_bytes limit caused input file truncation
  2. kForceOptimized filtering removed all files in the truncated batch

Root Cause:
The original code at line 784 would return nullptr immediately when inputs_shrunk was empty, without checking if covering_the_whole_range was false (indicating more files beyond the size limit).

The Fix:
Set compaction_end to signal the caller to continue with remaining files when the two conditions are met

Fixes #12702

Test Plan:

make db_compaction_test
./db_compaction_test --gtest_filter="DBCompactionTest.ManualCompactionBottomLevelOptimized"

@meta-cla meta-cla bot added the CLA Signed label Nov 8, 2025
…ook#12702)

Summary:
Fix a bug where CompactRange with BottommostLevelCompaction::kForceOptimized
would incorrectly return early when two conditions occurred simultaneously:
1. max_compaction_bytes limit caused input file truncation
2. kForceOptimized filtering removed all files in the truncated batch

**Root Cause:**
The original code at line 784 would return nullptr immediately when
inputs_shrunk was empty, without checking if covering_the_whole_range
was false (indicating more files beyond the size limit).

**The Fix:**
1. Check covering_the_whole_range before returning nullptr when
   inputs_shrunk is empty
2. If covering_the_whole_range is false, set compaction_end to signal
   the caller to continue with remaining files
3. Fix the loop checking remaining files to use inputs_shrunk (which
   contains the original file list after the swap)

Fixes facebook#12702

Test Plan:

make db_compaction_test
./db_compaction_test --gtest_filter="DBCompactionTest.ManualCompactionBottomLevelOptimized"
@ywave620
Copy link
Contributor Author

@cbi42 Could you review this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CompactRange with option BottommostLevelCompaction::kForceOptimized doesn't work correctly in route split situation. Rocksdb v6.29.5

1 participant