diff --git a/HISTORY.md b/HISTORY.md index 0227580ad..0f70d3269 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -9,6 +9,7 @@ * Added is_manual_compaction to CompactionFilter::Context * Added "virtual void WaitForJoin() = 0" in class Env * Removed BackupEngine::DeleteBackupsNewerThan() function +* Added new option -- verify_checksums_in_compaction ### New Features * If we find one truncated record at the end of the MANIFEST or WAL files, diff --git a/db/version_set.cc b/db/version_set.cc index d47b043d2..14df94471 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -2179,6 +2179,7 @@ Compaction* VersionSet::CompactRange(int input_level, int output_level, Iterator* VersionSet::MakeInputIterator(Compaction* c) { ReadOptions options; + options.verify_checksums = options_->verify_checksums_in_compaction; options.fill_cache = false; // Level-0 files have to be merged together. For other levels, diff --git a/include/rocksdb/options.h b/include/rocksdb/options.h index 53ea97b14..c3371b8bf 100644 --- a/include/rocksdb/options.h +++ b/include/rocksdb/options.h @@ -612,6 +612,11 @@ struct Options { // The options needed to support Universal Style compactions CompactionOptionsUniversal compaction_options_universal; + // If true, compaction will verify checksum on every read that happens + // as part of compaction + // Default: true + bool verify_checksums_in_compaction; + // Use KeyMayExist API to filter deletes when this is true. // If KeyMayExist returns false, i.e. the key definitely does not exist, then // the delete is a noop. KeyMayExist only incurs in-memory look up. diff --git a/util/options.cc b/util/options.cc index 22e273a8c..17ef3da9f 100644 --- a/util/options.cc +++ b/util/options.cc @@ -101,6 +101,7 @@ Options::Options() use_adaptive_mutex(false), bytes_per_sync(0), compaction_style(kCompactionStyleLevel), + verify_checksums_in_compaction(true), filter_deletes(false), max_sequential_skip_in_iterations(8), memtable_factory(std::shared_ptr(new SkipListFactory)), @@ -278,6 +279,8 @@ Options::Dump(Logger* log) const (unsigned long)bytes_per_sync); Log(log," Options.filter_deletes: %d", filter_deletes); + Log(log, " Options.verify_checksums_in_compaction: %d", + verify_checksums_in_compaction); Log(log," Options.compaction_style: %d", compaction_style); Log(log," Options.compaction_options_universal.size_ratio: %u",