Fix CompactionJob::Install division by zero

Summary:
Fix CompactionJob::Install division by zero
Closes https://github.com/facebook/rocksdb/pull/1580

Differential Revision: D4240794

Pulled By: IslamAbdelRahman

fbshipit-source-id: 7286721
main
Islam AbdelRahman 8 years ago committed by Facebook Github Bot
parent 63c30de80d
commit 1886c435b9
  1. 20
      db/compaction_job.cc

@ -590,6 +590,16 @@ Status CompactionJob::Install(const MutableCFOptions& mutable_cf_options) {
VersionStorageInfo::LevelSummaryStorage tmp; VersionStorageInfo::LevelSummaryStorage tmp;
auto vstorage = cfd->current()->storage_info(); auto vstorage = cfd->current()->storage_info();
const auto& stats = compaction_stats_; const auto& stats = compaction_stats_;
double read_write_amp = 0.0;
double write_amp = 0.0;
if (stats.bytes_read_non_output_levels > 0) {
read_write_amp = (stats.bytes_written + stats.bytes_read_output_level +
stats.bytes_read_non_output_levels) /
static_cast<double>(stats.bytes_read_non_output_levels);
write_amp = stats.bytes_written /
static_cast<double>(stats.bytes_read_non_output_levels);
}
LogToBuffer( LogToBuffer(
log_buffer_, log_buffer_,
"[%s] compacted to: %s, MB/sec: %.1f rd, %.1f wr, level %d, " "[%s] compacted to: %s, MB/sec: %.1f rd, %.1f wr, level %d, "
@ -602,16 +612,10 @@ Status CompactionJob::Install(const MutableCFOptions& mutable_cf_options) {
stats.bytes_written / static_cast<double>(stats.micros), stats.bytes_written / static_cast<double>(stats.micros),
compact_->compaction->output_level(), compact_->compaction->output_level(),
stats.num_input_files_in_non_output_levels, stats.num_input_files_in_non_output_levels,
stats.num_input_files_in_output_level, stats.num_input_files_in_output_level, stats.num_output_files,
stats.num_output_files,
stats.bytes_read_non_output_levels / 1048576.0, stats.bytes_read_non_output_levels / 1048576.0,
stats.bytes_read_output_level / 1048576.0, stats.bytes_read_output_level / 1048576.0,
stats.bytes_written / 1048576.0, stats.bytes_written / 1048576.0, read_write_amp, write_amp,
(stats.bytes_written + stats.bytes_read_output_level +
stats.bytes_read_non_output_levels) /
static_cast<double>(stats.bytes_read_non_output_levels),
stats.bytes_written /
static_cast<double>(stats.bytes_read_non_output_levels),
status.ToString().c_str(), stats.num_input_records, status.ToString().c_str(), stats.num_input_records,
stats.num_dropped_records); stats.num_dropped_records);

Loading…
Cancel
Save