mirror of https://github.com/facebook/rocksdb.git
Fixed issues Valgrind found.
Summary: Found issues with `db_test` and `db_stress` when running valgrind. `DBImpl` had an issue where if an compaction failed then it will use the uninitialised file size of an output file is used. This manifested as the final call to output to the log in `DoCompactionWork()` branching on uninitialized memory (all the way down in printf's innards). Test Plan: Ran `valgrind --track_origins=yes ./db_test` and `valgrind ./db_stress` to see if issues disappeared. Ran `make check` to see if there were no regressions. Reviewers: vamsi, dhruba Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D8001
This commit is contained in:
parent
dfcf6136cc
commit
3c3df7402f
|
@ -1717,7 +1717,14 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) {
|
||||||
|
|
||||||
stats.files_in_leveln = compact->compaction->num_input_files(0);
|
stats.files_in_leveln = compact->compaction->num_input_files(0);
|
||||||
stats.files_in_levelnp1 = compact->compaction->num_input_files(1);
|
stats.files_in_levelnp1 = compact->compaction->num_input_files(1);
|
||||||
stats.files_out_levelnp1 = compact->outputs.size();
|
|
||||||
|
int num_output_files = compact->outputs.size();
|
||||||
|
if (compact->builder != NULL) {
|
||||||
|
// An error occured so ignore the last output.
|
||||||
|
assert(num_output_files > 0);
|
||||||
|
--num_output_files;
|
||||||
|
}
|
||||||
|
stats.files_out_levelnp1 = num_output_files;
|
||||||
|
|
||||||
for (int i = 0; i < compact->compaction->num_input_files(0); i++)
|
for (int i = 0; i < compact->compaction->num_input_files(0); i++)
|
||||||
stats.bytes_readn += compact->compaction->input(0, i)->file_size;
|
stats.bytes_readn += compact->compaction->input(0, i)->file_size;
|
||||||
|
@ -1725,7 +1732,7 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) {
|
||||||
for (int i = 0; i < compact->compaction->num_input_files(1); i++)
|
for (int i = 0; i < compact->compaction->num_input_files(1); i++)
|
||||||
stats.bytes_readnp1 += compact->compaction->input(1, i)->file_size;
|
stats.bytes_readnp1 += compact->compaction->input(1, i)->file_size;
|
||||||
|
|
||||||
for (size_t i = 0; i < compact->outputs.size(); i++) {
|
for (int i = 0; i < num_output_files; i++) {
|
||||||
stats.bytes_written += compact->outputs[i].file_size;
|
stats.bytes_written += compact->outputs[i].file_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -678,19 +678,19 @@ class StressTest {
|
||||||
fprintf(stdout, "Num keys per lock : %d\n",
|
fprintf(stdout, "Num keys per lock : %d\n",
|
||||||
1 << FLAGS_log2_keys_per_lock);
|
1 << FLAGS_log2_keys_per_lock);
|
||||||
|
|
||||||
char* compression = (char *)std::string("").c_str();
|
const char* compression = "";
|
||||||
switch (FLAGS_compression_type) {
|
switch (FLAGS_compression_type) {
|
||||||
case leveldb::kNoCompression:
|
case leveldb::kNoCompression:
|
||||||
compression = (char *)std::string("none").c_str();
|
compression = "none";
|
||||||
break;
|
break;
|
||||||
case leveldb::kSnappyCompression:
|
case leveldb::kSnappyCompression:
|
||||||
compression = (char *)std::string("snappy").c_str();
|
compression = "snappy";
|
||||||
break;
|
break;
|
||||||
case leveldb::kZlibCompression:
|
case leveldb::kZlibCompression:
|
||||||
compression = (char *)std::string("zlib").c_str();
|
compression = "zlib";
|
||||||
break;
|
break;
|
||||||
case leveldb::kBZip2Compression:
|
case leveldb::kBZip2Compression:
|
||||||
compression = (char *)std::string("bzip2").c_str();
|
compression = "bzip2";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue