From a8d3aa2c26eecdab268d2634a49eb325587a7efb Mon Sep 17 00:00:00 2001 From: Dhruba Borthakur Date: Wed, 8 May 2013 10:19:24 -0700 Subject: [PATCH] Assertion failure for L0-L1 compactions. Summary: For level-0 compactions, we try to find if can include more L0 files in the same compaction run. This causes the 'smallest' and 'largest' key to get extended to a larger range. But the suceeding call to ParentRangeInCompaction() was still using the earlier values of 'smallest' and 'largest', Because of this bug, a file in L1 can be part of two concurrent compactions: one L0-L1 compaction and the other L1-L2 compaction. This should not cause any data loss, but will cause an assertion failure with debug builds. Test Plan: make check Differential Revision: https://reviews.facebook.net/D10677 --- db/version_set.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/version_set.cc b/db/version_set.cc index 428ceaff9..a621be967 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -2082,6 +2082,11 @@ Compaction* VersionSet::PickCompaction() { // which will include the picked file. c->inputs_[0].clear(); current_->GetOverlappingInputs(0, &smallest, &largest, &c->inputs_[0]); + + // If we include more L0 files in the same compaction run it can + // cause the 'smallest' and 'largest' key to get extended to a + // larger range. So, re-invoke GetRange to get the new key range + GetRange(c->inputs_[0], &smallest, &largest); if (ParentRangeInCompaction(&smallest, &largest, level, &c->parent_index_)) { delete c;