Max_mem_compaction_level can have maximum value of num_levels-1

Summary:
Without this files could be written out to a level greater than the maximum level possible and is the source of the segfaults that wormhole awas getting. The sequence of steps that was followed:
1. WriteLevel0Table was called when memtable was to be flushed for a file.
2. PickLevelForMemTableOutput was called to determine the level to which this file should be pushed.
3. PickLevelForMemTableOutput returned a wrong result because max_mem_compaction_level was equal to 2 even when num_levels was equal to 0.
The fix to re-initialize max_mem_compaction_level based on num_levels passed seems correct.

Test Plan: make all check; Also made a dummy file to mimic the wormhole-file behaviour which was causing the segfaults and found that the same segfault occurs without this change and not with this.

Reviewers: dhruba, haobo

Reviewed By: dhruba

CC: leveldb

Differential Revision: https://reviews.facebook.net/D11157
This commit is contained in:
Mayank Agarwal 2013-06-08 20:15:10 -07:00
parent 7a6bd8e975
commit 184343a061

View File

@ -141,6 +141,9 @@ Options SanitizeOptions(const std::string& dbname,
if (result.block_size_deviation < 0 || result.block_size_deviation > 100) { if (result.block_size_deviation < 0 || result.block_size_deviation > 100) {
result.block_size_deviation = 0; result.block_size_deviation = 0;
} }
if (result.max_mem_compaction_level >= result.num_levels) {
result.max_mem_compaction_level = result.num_levels - 1;
}
return result; return result;
} }