Overview
The SST Dump Tool (sst_dump) is a specialized utility for examining RocksDB’s SST (Sorted String Table) files. It provides detailed insights into SST file structure, contents, metadata, and compression efficiency.
Building sst_dump
Build the tool:Basic Usage
The general syntax:Commands
The--command flag specifies the operation mode:
Check (Default)
Verify SST file integrity by iterating through all entries:1
Validation performed
- Iterates over all key-value pairs
- Compares entry count with metadata
- Reports corruption if mismatch detected
2
Silent on success
Only prints output if errors are encountered
Scan
Iterate through entries and print them to screen:Raw
Dump complete table contents to a file:000123.sst_dump.txt with:
- All key-value pairs
- Block structure details
- Footer information
- Index block contents
Verify
Verify checksums for all blocks without printing data:Use
verify to detect corruption without the overhead of decoding keys and values. It’s faster than check for large files.Recompress
Analyze file size with different compression algorithms:Identify
Check if file is a valid SST file:Filtering and Range Options
Key Range Scanning
1
From key
Start scanning from a specific key:
2
To key
Stop scanning at a specific key:
3
Prefix scan
Scan all keys with a specific prefix:
Cannot be used with
--from optionHex Key Input
When working with binary keys:Display Options
Show Properties
Display table properties after iteration:- Data size
- Index size
- Filter size
- Number of entries
- Number of data blocks
- Compression type
- User-collected properties
Show Sequence Numbers
Display sequence numbers and value types (for raw dumps):Decode Blob Index
For SST files containing blob references:List Meta Blocks
Show all metadata blocks in the file:Compression Analysis
Testing Multiple Compression Types
Custom Block Size
Test recompression with different block sizes:Compression Levels
Test a range of compression levels:Index Compression
Enable compression for index blocks:Dictionary Compression
Configure dictionary-based compression:Advanced Options
Verify Checksum
Enable checksum verification during scans:Readahead Size
Optimize I/O with readahead:Environment and Filesystem URIs
Use custom environments or filesystems:--env_uri and --fs_uri are mutually exclusive.Internal Key Parsing
Parse internal key format on command line:Practical Examples
Diagnose Corruption
1
Identify corrupted file
2
Locate bad block
3
Extract good data
Optimize Compression
1
Test all compression types
2
Fine-tune best algorithm
3
Test with dictionary
Export Key Range
Extract specific key range from SST file:Inspect File Properties
Analyze All Files in Directory
Understanding Output
Scan Output Format
key @ sequence_number : type => value
Value types:
1= kTypeValue (regular put)0= kTypeDeletion (delete)2= kTypeMerge (merge)7= kTypeDeletionWithTimestamp
Properties Output
Example output from--show_properties:
Common Options Reference
Performance Tips
Source Reference
SST Dump Tool implementation:include/rocksdb/sst_dump_tool.h:11-14- Public API (simple Run interface)tools/sst_dump_tool.cc:167-400- Command-line parsing and tool implementationtable/sst_file_dumper.handtable/sst_file_dumper.cc- Core SST file reading logic