nodetool upgradesstables
Rewrites SSTables to the SSTable format version supported by the running Cassandra instance.
Synopsis
Section titled “Synopsis”nodetool [connection_options] upgradesstables [options] [--] [keyspace [table ...]]See connection options for connection options.
Description
Section titled “Description”nodetool upgradesstables rewrites SSTables that were created by older Cassandra versions into the SSTable format corresponding to the currently running Cassandra version. The target format is determined automatically by the Cassandra instance—each major Cassandra release introduces a new SSTable format version with improvements to encoding, compression, and metadata storage.
This operation is recommended after upgrading Cassandra to ensure all SSTables benefit from the latest format's features and optimizations. SSTables already in the current format are skipped unless the -a flag is specified.
Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
keyspace | Keyspace to upgrade. If omitted, upgrades all keyspaces |
table | Specific table(s) to upgrade |
Options
Section titled “Options”| Option | Description |
|---|---|
-a, --include-all-sstables | Upgrade all SSTables, even if already current version |
-j, --jobs <jobs> | Number of concurrent upgrade jobs (default: 2). Use 0 to use all available compaction threads. |
-t, --max-timestamp <timestamp> | Only upgrade SSTables with max timestamp older than the specified value (epoch time in seconds) |
When to Run
Section titled “When to Run”After Cassandra Upgrade
Section titled “After Cassandra Upgrade”# After upgrading from 4.0 to 4.1nodetool upgradesstablesCheck SSTable Versions First
Section titled “Check SSTable Versions First”# See which versions existls /var/lib/cassandra/data/my_keyspace/my_table-*/# Look for version prefixes: mc-, nb-, etc.| Prefix | Cassandra Version |
|---|---|
mc- | 3.0+ |
nb- | 4.0+ |
nc- | 5.0+ |
Examples
Section titled “Examples”Upgrade All SSTables
Section titled “Upgrade All SSTables”nodetool upgradesstablesUpgrade Specific Keyspace
Section titled “Upgrade Specific Keyspace”nodetool upgradesstables my_keyspaceUpgrade Specific Table
Section titled “Upgrade Specific Table”nodetool upgradesstables my_keyspace my_tableForce Upgrade All (Including Current)
Section titled “Force Upgrade All (Including Current)”nodetool upgradesstables -a my_keyspaceParallel Upgrade
Section titled “Parallel Upgrade”nodetool upgradesstables -j 4 my_keyspaceUse All Available Compaction Threads
Section titled “Use All Available Compaction Threads”nodetool upgradesstables -j 0 my_keyspaceUpgrade Only Old SSTables
Section titled “Upgrade Only Old SSTables”# Upgrade SSTables older than 30 days (timestamp in epoch seconds)nodetool upgradesstables -t $(date -d '30 days ago' +%s) my_keyspaceProcess
Section titled “Process”- Identify SSTables with older format version
- Read data from old SSTable
- Write data to new SSTable in current format
- Replace old SSTable with new one
- Remove old SSTable files
Disk Space Requirements
Section titled “Disk Space Requirements”Space Needed
Like compaction, upgradesstables needs temporary space:
Space needed ≈ Size of largest SSTable being upgradedCheck available space:
df -h /var/lib/cassandra/dataMonitoring Progress
Section titled “Monitoring Progress”Check Running Upgrades
Section titled “Check Running Upgrades”nodetool compactionstatsUpgrade appears as a compaction operation with type "Upgrade".
Watch Progress
Section titled “Watch Progress”watch -n 5 'nodetool compactionstats | grep -i upgrade'Performance Impact
Section titled “Performance Impact”I/O Intensive
- Reads all qualifying SSTables
- Writes new SSTables
- Similar to major compaction
- Run during low-traffic periods
Recommended Approach
Section titled “Recommended Approach”# 1. Run on one node at a time# 2. Start with smaller keyspacesnodetool upgradesstables system_schemanodetool upgradesstables system
# 3. Then production keyspacesnodetool upgradesstables production_ksUpgrade Order After Version Upgrade
Section titled “Upgrade Order After Version Upgrade”# 1. System keyspaces firstnodetool upgradesstables system_schemanodetool upgradesstables systemnodetool upgradesstables system_authnodetool upgradesstables system_distributednodetool upgradesstables system_traces
# 2. Application keyspacesnodetool upgradesstables my_app_keyspaceCommon Issues
Section titled “Common Issues”Upgrade Takes Too Long
Section titled “Upgrade Takes Too Long”Large tables take significant time:
# Check progressnodetool compactionstats
# Consider upgrading table by tablenodetool upgradesstables my_keyspace small_tablenodetool upgradesstables my_keyspace medium_tablenodetool upgradesstables my_keyspace large_tableNot Enough Disk Space
Section titled “Not Enough Disk Space”# Free space firstnodetool clearsnapshot
# Or upgrade one table at a timenodetool upgradesstables my_keyspace table1# Wait for completionnodetool upgradesstables my_keyspace table2SSTables Already Current
Section titled “SSTables Already Current”If all SSTables are already current version:
Nothing to upgrade for my_keyspace.my_tableThis is expected and not an error.
Skipping Upgradesstables
Section titled “Skipping Upgradesstables”Not Recommended
Skipping upgradesstables after a major version upgrade may cause:
- Reduced performance (old format not optimized)
- Compatibility issues
- Problems during repair
- Issues with new features
Automation Script
Section titled “Automation Script”#!/bin/bashLOG="/var/log/cassandra/upgrade_sstables_$(date +%Y%m%d).log"
echo "Starting SSTable upgrade at $(date)" >> $LOG
# System keyspaces firstfor ks in system_schema system system_auth system_distributed system_traces; do echo "Upgrading $ks..." >> $LOG nodetool upgradesstables $ks >> $LOG 2>&1done
# Then all user keyspacesfor ks in $(nodetool tablestats 2>/dev/null | grep "Keyspace:" | awk '{print $2}' | grep -v "^system"); do echo "Upgrading $ks..." >> $LOG nodetool upgradesstables $ks >> $LOG 2>&1done
echo "Completed at $(date)" >> $LOGBest Practices
Section titled “Best Practices”Upgrade Guidelines
- Run after every major upgrade - Essential for compatibility
- System keyspaces first - They're smaller and critical
- One node at a time - Reduce cluster impact
- Check disk space - Ensure sufficient room
- Monitor progress - Watch compactionstats
- Run during maintenance window - High I/O impact
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| compactionstats | Monitor upgrade progress |
| scrub | Rewrite SSTables (for corruption) |
| compact | Force compaction |
| tablestats | View SSTable counts |