sstableutil
Lists SSTable files belonging to a table, including active, temporary, and obsolete files.
Synopsis
Section titled “Synopsis”sstableutil [options] <keyspace> <table>Description
Section titled “Description”sstableutil provides a listing of SSTable files associated with a table, including active (final) SSTables and temporary files from in-progress operations.
This tool is useful for:
- Identifying SSTable files before running other SSTable tools
- Diagnosing cleanup issues - Finding orphaned or obsolete files
- Understanding storage layout - Seeing all files for a table
- Pre-operation verification - Confirming SSTable paths before maintenance
Safe to Run While Cassandra Is Active
sstableutil can safely run while Cassandra is active. It performs read-only filesystem operations.
Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
keyspace | Name of the keyspace containing the table |
table | Name of the table to list SSTables for |
Options
Section titled “Options”| Option | Description |
|---|---|
-c, --cleanup | Perform cleanup - removes unfinished transaction leftovers (destructive) |
-d, --debug | Enable debug output |
-o, --oplog | Include transaction log files |
-t, --type <type> | Filter by SSTable type: tmp, final, all |
-v, --verbose | Enable verbose output |
-h, --help | Display help information |
Cleanup is Destructive
The --cleanup option does not just list files—it actively removes unfinished transaction leftovers by calling LifecycleTransaction.removeUnfinishedLeftovers(). Use with caution and only when Cassandra is stopped.
Examples
Section titled “Examples”List All SSTables
Section titled “List All SSTables”# List all SSTable files for a tablesstableutil my_keyspace my_tableList Active SSTables Only
Section titled “List Active SSTables Only”# Only show final (active) SSTablessstableutil -t final my_keyspace my_tableList Temporary Files
Section titled “List Temporary Files”# Show temporary files from in-progress operationssstableutil -t tmp my_keyspace my_tablePerform Cleanup
Section titled “Perform Cleanup”# Remove unfinished transaction leftovers (DESTRUCTIVE)# Only run when Cassandra is stoppedsstableutil --cleanup my_keyspace my_tableInclude Transaction Logs
Section titled “Include Transaction Logs”# Also show transaction log filessstableutil --oplog my_keyspace my_tableOutput Format
Section titled “Output Format”Standard Output
Section titled “Standard Output”Listing files for my_keyspace.my_table/var/lib/cassandra/data/my_keyspace/my_table-a1b2c3d4/nb-1-big-CompressionInfo.db/var/lib/cassandra/data/my_keyspace/my_table-a1b2c3d4/nb-1-big-Data.db/var/lib/cassandra/data/my_keyspace/my_table-a1b2c3d4/nb-1-big-Digest.crc32/var/lib/cassandra/data/my_keyspace/my_table-a1b2c3d4/nb-1-big-Filter.db/var/lib/cassandra/data/my_keyspace/my_table-a1b2c3d4/nb-1-big-Index.db/var/lib/cassandra/data/my_keyspace/my_table-a1b2c3d4/nb-1-big-Statistics.db/var/lib/cassandra/data/my_keyspace/my_table-a1b2c3d4/nb-1-big-Summary.db/var/lib/cassandra/data/my_keyspace/my_table-a1b2c3d4/nb-1-big-TOC.txt/var/lib/cassandra/data/my_keyspace/my_table-a1b2c3d4/nb-2-big-CompressionInfo.db/var/lib/cassandra/data/my_keyspace/my_table-a1b2c3d4/nb-2-big-Data.db...SSTable Components
Section titled “SSTable Components”Each SSTable consists of multiple component files:
| Component | Extension | Description |
|---|---|---|
| Data | -Data.db | Actual row data |
| Index | -Index.db | Partition index |
| Filter | -Filter.db | Bloom filter |
| Statistics | -Statistics.db | SSTable metadata |
| Summary | -Summary.db | Index summary |
| Compression | -CompressionInfo.db | Compression metadata |
| Digest | -Digest.crc32 | Data checksum |
| TOC | -TOC.txt | Table of contents |
Understanding SSTable Names
Section titled “Understanding SSTable Names”Naming Convention
Section titled “Naming Convention”<version>-<generation>-<format>-<component>.<extension>
Example: nb-1-big-Data.db │ │ │ │ │ │ │ └── Component type │ │ └─────── Format (big = standard) │ └────────── Generation number └───────────── Version (nb = 4.0)Version Codes
Section titled “Version Codes”| Code | Cassandra Version |
|---|---|
| jb | 2.0.x |
| ka | 2.1.x |
| la | 2.2.x |
| ma | 3.0.x |
| mb | 3.11.x |
| nb | 4.0.x |
| nc | 4.1.x |
| oa | 5.0.x |
Common Use Cases
Section titled “Common Use Cases”Find SSTable Paths for Other Tools
Section titled “Find SSTable Paths for Other Tools”# Get Data.db paths for sstablemetadatasstableutil my_keyspace my_table | grep "Data.db$"
# Use with sstablemetadatafor f in $(sstableutil my_keyspace my_table | grep "Data.db$"); do sstablemetadata "$f"doneCount SSTables
Section titled “Count SSTables”# Count number of SSTables for a tablesstableutil my_keyspace my_table | grep -c "Data.db$"Calculate Total Size
Section titled “Calculate Total Size”#!/bin/bash# sstable_size.sh - Calculate total SSTable size
KEYSPACE="$1"TABLE="$2"
total_size=0for f in $(sstableutil "$KEYSPACE" "$TABLE"); do size=$(stat -c%s "$f" 2>/dev/null) total_size=$((total_size + size))done
echo "Total size: $((total_size / 1024 / 1024)) MB"Find Orphaned Files
Section titled “Find Orphaned Files”#!/bin/bash# find_orphaned.sh - Find files not tracked by Cassandra
KEYSPACE="$1"TABLE="$2"DATA_DIR="/var/lib/cassandra/data"
# Get tracked filestracked=$(sstableutil "$KEYSPACE" "$TABLE" | sort)
# Get all files in directoryall_files=$(find ${DATA_DIR}/${KEYSPACE}/${TABLE}-*/ -type f ! -name "*.log" | sort)
echo "Files not tracked by Cassandra:"comm -13 <(echo "$tracked") <(echo "$all_files")Pre-Tool Verification
Section titled “Pre-Tool Verification”#!/bin/bash# pre_tool_check.sh - Verify SSTables before running offline tools
KEYSPACE="$1"TABLE="$2"
echo "SSTable verification for ${KEYSPACE}.${TABLE}"echo "============================================="
# Check for active SSTablesecho ""echo "Active SSTables:"sstableutil -t final "$KEYSPACE" "$TABLE" | grep "Data.db$" | wc -l
# Check for temporary filesecho ""echo "Temporary files:"tmp_count=$(sstableutil -t tmp "$KEYSPACE" "$TABLE" | wc -l)if [ "$tmp_count" -gt 0 ]; then echo "WARNING: $tmp_count temporary files found" echo "An operation may be in progress" sstableutil -t tmp "$KEYSPACE" "$TABLE"else echo "None"fi
# Check for obsolete filesecho ""echo "Obsolete files:"obsolete_count=$(sstableutil --cleanup "$KEYSPACE" "$TABLE" | wc -l)if [ "$obsolete_count" -gt 0 ]; then echo "WARNING: $obsolete_count obsolete files found" sstableutil --cleanup "$KEYSPACE" "$TABLE"else echo "None"fiSSTable File Types
Section titled “SSTable File Types”Final (Active) SSTables
Section titled “Final (Active) SSTables”Active SSTables currently being used by Cassandra:
sstableutil -t final my_keyspace my_tableTemporary Files
Section titled “Temporary Files”Files from in-progress operations (compaction, streaming):
sstableutil -t tmp my_keyspace my_tableTemporary files may indicate:
- Active compaction
- Active streaming
- Incomplete operation (if Cassandra crashed)
Cleanup Mode
Section titled “Cleanup Mode”The --cleanup option removes unfinished transaction leftovers:
# Performs cleanup (destructive) - only when Cassandra is stoppedsstableutil --cleanup my_keyspace my_tableThis is useful after a crash to clean up incomplete operations.
Transaction Logs
Section titled “Transaction Logs”Transaction logs track pending SSTable operations:
sstableutil --oplog my_keyspace my_tableTransaction Log Files
Section titled “Transaction Log Files”| File Pattern | Purpose |
|---|---|
*.log | Pending operation log |
*_txn_*.log | Transaction in progress |
Transaction logs ensure atomicity of SSTable operations. They should be automatically cleaned up after operations complete.
Troubleshooting
Section titled “Troubleshooting”No SSTables Found
Section titled “No SSTables Found”# Check if table existscqlsh -e "DESCRIBE TABLE my_keyspace.my_table;"
# Check data directoryls -la /var/lib/cassandra/data/my_keyspace/
# Table may be empty - check with flush firstnodetool flush my_keyspace my_tablesstableutil my_keyspace my_tablePermission Denied
Section titled “Permission Denied”# Run as cassandra usersudo -u cassandra sstableutil my_keyspace my_table
# Or check permissionsls -la /var/lib/cassandra/data/my_keyspace/my_table-*/Stale Temporary Files
Section titled “Stale Temporary Files”If temporary files persist after Cassandra restart:
# Check for stale temp filessstableutil -t tmp my_keyspace my_table
# If Cassandra is stopped and these are from crashed operations:# They can usually be safely deleted# But verify Cassandra is stopped first!Best Practices
Section titled “Best Practices”sstableutil Guidelines
- Use before other tools - Verify paths before running offline tools
- Check for temp files - Before maintenance, ensure no operations in progress
- Regular cleanup checks - Monitor for accumulating obsolete files
- Verify snapshots - Confirm snapshot contents before restores
- Script integration - Use in automation scripts for path discovery
- Safe operation - Can run while Cassandra is active
Safe Operation
sstableutil is completely read-only and safe to run at any time, whether Cassandra is running or not.
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| sstablemetadata | Get metadata for listed SSTables |
| sstabledump | Dump data from listed SSTables |
| sstableverify | Verify listed SSTables |
| nodetool cleanup | Remove obsolete files |
| nodetool compact | Compact SSTables |