Skip to content

Commit 13e3c4e

Browse files
ghemawatpwnall
authored andcommitted
Fix compactions that could end up breaking a run of the same user
key across multiple files. As reported in Github issue google#339, it is incorrect to split the same user key across multiple compacted files since it causes tombstones/newer-versions to be dropped, thereby exposing obsolete data. There was a fix for google#339, but it ended up not fully fixing the problem. (It checked for boundary problems in the first level being compacted, but not the second). This problem was revealed by Github issue 887. We now adjust boundaries to avoid splitting user keys in both the first level and the second level. PiperOrigin-RevId: 374921082
1 parent f57513a commit 13e3c4e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

db/version_set.cc

+2
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,7 @@ void VersionSet::SetupOtherInputs(Compaction* c) {
13921392

13931393
current_->GetOverlappingInputs(level + 1, &smallest, &largest,
13941394
&c->inputs_[1]);
1395+
AddBoundaryInputs(icmp_, current_->files_[level + 1], &c->inputs_[1]);
13951396

13961397
// Get entire range covered by compaction
13971398
InternalKey all_start, all_limit;
@@ -1414,6 +1415,7 @@ void VersionSet::SetupOtherInputs(Compaction* c) {
14141415
std::vector<FileMetaData*> expanded1;
14151416
current_->GetOverlappingInputs(level + 1, &new_start, &new_limit,
14161417
&expanded1);
1418+
AddBoundaryInputs(icmp_, current_->files_[level + 1], &expanded1);
14171419
if (expanded1.size() == c->inputs_[1].size()) {
14181420
Log(options_->info_log,
14191421
"Expanding@%d %d+%d (%ld+%ld bytes) to %d+%d (%ld+%ld bytes)\n",

0 commit comments

Comments
 (0)