Question about `Compaction::ShouldStopBefore()`
- Dominant language
- C++
- Stars
- 39.4k
- Forks
- 8.2k
- PR merge metrics
- No merged PRs in 30d
Description
I am reading leveldb recently. In function [`DBImpl::DoCompactionWork()`](https://github.com/google/leveldb/blob/master/db/db_impl.cc#L887), it will call [`Compaction::ShouldStopBefore`](https://github.com/google/leveldb/blob/master/db/version_set.cc#L1531) for every key. According to file impl.md, `Compaction::ShouldStopBefore()` is used to avoid that an output file overlaps two much grandparent(level+2) files.
When an output file is too large, it will close and create a new output file. But the state of `Compaction::ShouldStopBefore()` seems not to change, so `overlapped_bytes_` used in `Compaction::ShouldStopBefore()` will keep rising when a new output file is used. Have I missed something? or it is designed to be so? or it is a bug?
Contributor guide
Research direction
Start by reading db/db_impl.cc at DoCompactionWork(), version_set.cc at Compaction::ShouldStopBefore(), and impl.md. Trace how overlapped_bytes_ and output-file state behave across compaction outputs, then document whether the behavior is intentional or a bug and identify any needed follow-up.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100