From c53d604f4114baa6e06e90e204850c36d6f35765 Mon Sep 17 00:00:00 2001 From: Changyu Bi Date: Wed, 5 Jul 2023 14:12:06 -0700 Subject: [PATCH] `sst_dump --command=verify` should verify block checksums (#11576) Summary: `sst_dump --command=verify` did not set read_options.verify_checksum to true so it was not verifying checksum. Pull Request resolved: https://github.com/facebook/rocksdb/pull/11576 Test Plan: ran the same command on an SST file with bad checksum: ``` sst_dump --command=verify --file=...sst_file_with_bad_block_checksum Before this PR: options.env is 0x6ba048 Process ...sst_file_with_bad_block_checksum Sst file format: block-based The file is ok After this PR: options.env is 0x7f43f6690000 Process ...sst_file_with_bad_block_checksum Sst file format: block-based ... is corrupted: Corruption: block checksum mismatch: stored = 2170109798, computed = 2170097510, type = 4 ... ``` Reviewed By: ajkr Differential Revision: D47136284 Pulled By: cbi42 fbshipit-source-id: 07d68db715c00347145e5b83d649aef2c3f2acd9 --- table/sst_file_dumper.cc | 1 + tools/sst_dump_tool.cc | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/table/sst_file_dumper.cc b/table/sst_file_dumper.cc index da91c1130..85a264d59 100644 --- a/table/sst_file_dumper.cc +++ b/table/sst_file_dumper.cc @@ -196,6 +196,7 @@ Status SstFileDumper::NewTableReader( } Status SstFileDumper::VerifyChecksum() { + assert(read_options_.verify_checksums); // We could pass specific readahead setting into read options if needed. return table_reader_->VerifyChecksum(read_options_, TableReaderCaller::kSSTDumpTool); diff --git a/tools/sst_dump_tool.cc b/tools/sst_dump_tool.cc index 87577ab8e..1b269043a 100644 --- a/tools/sst_dump_tool.cc +++ b/tools/sst_dump_tool.cc @@ -419,6 +419,10 @@ int SSTDumpTool::Run(int argc, char const* const* argv, Options options) { filename = std::string(dir_or_file) + "/" + filename; } + if (command == "verify") { + verify_checksum = true; + } + ROCKSDB_NAMESPACE::SstFileDumper dumper( options, filename, Temperature::kUnknown, readahead_size, verify_checksum, output_hex, decode_blob_index);