`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
oxigraph-main
Changyu Bi 1 year ago committed by Facebook GitHub Bot
parent 25b08eb438
commit c53d604f41
  1. 1
      table/sst_file_dumper.cc
  2. 4
      tools/sst_dump_tool.cc

@ -196,6 +196,7 @@ Status SstFileDumper::NewTableReader(
} }
Status SstFileDumper::VerifyChecksum() { Status SstFileDumper::VerifyChecksum() {
assert(read_options_.verify_checksums);
// We could pass specific readahead setting into read options if needed. // We could pass specific readahead setting into read options if needed.
return table_reader_->VerifyChecksum(read_options_, return table_reader_->VerifyChecksum(read_options_,
TableReaderCaller::kSSTDumpTool); TableReaderCaller::kSSTDumpTool);

@ -419,6 +419,10 @@ int SSTDumpTool::Run(int argc, char const* const* argv, Options options) {
filename = std::string(dir_or_file) + "/" + filename; filename = std::string(dir_or_file) + "/" + filename;
} }
if (command == "verify") {
verify_checksum = true;
}
ROCKSDB_NAMESPACE::SstFileDumper dumper( ROCKSDB_NAMESPACE::SstFileDumper dumper(
options, filename, Temperature::kUnknown, readahead_size, options, filename, Temperature::kUnknown, readahead_size,
verify_checksum, output_hex, decode_blob_index); verify_checksum, output_hex, decode_blob_index);

Loading…
Cancel
Save