Reset grandparents overlapped bytes after current output has been finished due to file size limitation

If current ouput is finished due to file size limitation, possibilities
exist that we hit grandparents overlapped bytes limitation after writing
fewer entries. So we need to restart grandparents overlapped bytes if we
start building a new output for reasons other than overlapped bytes with
grandparents.

This commit adds code to restart grandparents overlapped counting after
current output has been successfully finished due to file size
limitation.

I think the best place to restart grandparents overlapped counting
should be DBImpl::OpenCompactionOutputFile, thus we don't need to
remember to do this every time after we stop or start a output.
This commit is contained in:
Kezhu Wang 2016-05-10 00:46:11 +08:00
parent 9521545b06
commit 27445141b2
2 changed files with 5 additions and 0 deletions

View File

@ -992,6 +992,7 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) {
if (!status.ok()) {
break;
}
compact->compaction->RestartOverlappedBytes();
}
}

View File

@ -353,6 +353,10 @@ class Compaction {
// before processing "internal_key".
bool ShouldStopBefore(const Slice& internal_key);
// Reset overlapped bytes with grandparents. Should be called if we start
// building a new output for other reasons(eg. file size limitation).
void RestartOverlappedBytes() { overlapped_bytes_ = 0; }
// Release the input version for the compaction, once the compaction
// is successful.
void ReleaseInputs();