Fix SIGSEGV issue in universal compaction

Summary:
We saw SIGSEGV when set options.num_levels=1 in universal compaction
style. Dug into this issue for a while, and finally found the root cause (thank Haobo for discussion).

Test Plan: Add new unit test. It throws SIGSEGV without this change. Also run "make all check".

Reviewers: haobo, dhruba

CC: leveldb

Differential Revision: https://reviews.facebook.net/D13251
This commit is contained in:
Xing Jin
2013-10-02 16:20:17 -07:00
parent 6b34021fc2
commit 658a3ce2fa
2 changed files with 34 additions and 1 deletions

View File

@@ -2126,7 +2126,7 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) {
}
mutex_.Lock();
stats_[compact->compaction->level() + 1].Add(stats);
stats_[compact->compaction->output_level()].Add(stats);
// if there were any unused file number (mostly in case of
// compaction error), free up the entry from pending_putputs