summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanjay Ghemawat <sanjay@google.com>2021-05-20 19:02:41 +0000
committerVictor Costan <costan@google.com>2021-05-20 19:13:04 +0000
commit13e3c4efc66b8d7317c7648766a930b5d7e48aa7 (patch)
tree637179531450225a7c2228bbc2c485fddebd846d
parentf57513a1d6c99636fc5b710150d0b93713af4e43 (diff)
downloadleveldb-13e3c4efc66b8d7317c7648766a930b5d7e48aa7.tar.gz
Fix compactions that could end up breaking a run of the same user
key across multiple files. As reported in Github issue #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 #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
-rw-r--r--db/version_set.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/db/version_set.cc b/db/version_set.cc
index 1963353..8d85fce 100644
--- a/db/version_set.cc
+++ b/db/version_set.cc
@@ -1392,6 +1392,7 @@ void VersionSet::SetupOtherInputs(Compaction* c) {
current_->GetOverlappingInputs(level + 1, &smallest, &largest,
&c->inputs_[1]);
+ AddBoundaryInputs(icmp_, current_->files_[level + 1], &c->inputs_[1]);
// Get entire range covered by compaction
InternalKey all_start, all_limit;
@@ -1414,6 +1415,7 @@ void VersionSet::SetupOtherInputs(Compaction* c) {
std::vector<FileMetaData*> expanded1;
current_->GetOverlappingInputs(level + 1, &new_start, &new_limit,
&expanded1);
+ AddBoundaryInputs(icmp_, current_->files_[level + 1], &expanded1);
if (expanded1.size() == c->inputs_[1].size()) {
Log(options_->info_log,
"Expanding@%d %d+%d (%ld+%ld bytes) to %d+%d (%ld+%ld bytes)\n",