nodetool disableautocompaction
Disables automatic compaction for specified keyspaces and tables.
Synopsis
Section titled “Synopsis”nodetool [connection_options] disableautocompaction [--] [<keyspace> <tables>...]See connection options for connection options.
Description
Section titled “Description”nodetool disableautocompaction prevents automatic compaction from running on specified tables. While disabled, no new compaction tasks will be scheduled by the compaction strategy, though currently running compactions will complete.
Non-Persistent Setting
This setting is applied at runtime only and does not persist across node restarts. After a restart, auto-compaction is re-enabled based on the table's compaction strategy configuration.
There is no cassandra.yaml setting to globally disable auto-compaction. To persistently disable compaction for a specific table, set the compaction strategy's enabled option to false:
ALTER TABLE my_keyspace.my_tableWITH compaction = { 'class': 'LeveledCompactionStrategy', 'enabled': 'false'};This schema change persists across restarts but is generally not recommended for production use.
Disabling auto-compaction is useful for:
- Bulk data loading - Avoid compaction overhead during large imports
- Troubleshooting - Isolate compaction as a source of issues
- Controlled maintenance - Prevent compaction during specific operations
- Resource management - Temporarily free I/O and CPU resources
Use with Caution
Disabling auto-compaction for extended periods leads to serious performance degradation. SSTable counts grow unbounded, read performance suffers, and tombstones accumulate. Always re-enable promptly.
Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
keyspace | Target keyspace name. If omitted, applies to all keyspaces |
tables | Space-separated list of table names. If omitted, applies to all tables in the keyspace |
Examples
Section titled “Examples”Disable for All Keyspaces and Tables
Section titled “Disable for All Keyspaces and Tables”# Disable compaction on all tables (use carefully!)nodetool disableautocompactionDisable for Specific Keyspace
Section titled “Disable for Specific Keyspace”# Disable for all tables in a keyspacenodetool disableautocompaction my_keyspaceDisable for Specific Tables
Section titled “Disable for Specific Tables”# Disable for specific tables onlynodetool disableautocompaction my_keyspace users ordersWith Verification
Section titled “With Verification”# Disable and verifynodetool disableautocompaction my_keyspace my_tablenodetool statusautocompaction my_keyspace my_table# Expected: running=falseWhen to Use
Section titled “When to Use”Before Bulk Data Loading
Section titled “Before Bulk Data Loading”Disable compaction to avoid overhead during large imports:
# 1. Disable auto-compactionnodetool disableautocompaction my_keyspace my_table
# 2. Load data using sstableloadersstableloader -d node1,node2,node3 /path/to/sstables/
# 3. Re-enable after load completesnodetool enableautocompaction my_keyspace my_table
# 4. Force major compaction to consolidatenodetool compact my_keyspace my_tableDuring Troubleshooting
Section titled “During Troubleshooting”Isolate compaction when investigating performance issues:
# Stop compaction to see if it's the causenodetool disableautocompaction my_keyspace
# Monitor system behavior# ...
# Re-enable when donenodetool enableautocompaction my_keyspaceBefore Repair Operations
Section titled “Before Repair Operations”Some administrators disable during repair to reduce I/O contention:
# Disable compactionnodetool disableautocompaction my_keyspace
# Run repairnodetool repair -pr my_keyspace
# Re-enable compactionnodetool enableautocompaction my_keyspaceDuring Disk Space Emergency
Section titled “During Disk Space Emergency”Temporarily halt compaction when disk is critically full:
# Stop compaction (prevents additional space usage)nodetool disableautocompaction
# Free spacenodetool clearsnapshot --allrm -rf /var/lib/cassandra/data/*/*/backups/*
# Re-enable carefullynodetool enableautocompactionBehavior
Section titled “Behavior”What Happens When Disabled
Section titled “What Happens When Disabled”- No new compaction tasks are scheduled for the table
- Currently running compactions complete normally
- SSTables accumulate without merging
- Tombstones are not purged through compaction
- Disk space is not reclaimed from deleted data
What Continues to Work
Section titled “What Continues to Work”| Feature | Status |
|---|---|
| Reads | Continue (but may slow down) |
| Writes | Continue normally |
| Memtable flushes | Continue creating new SSTables |
| Streaming | Continues |
| Repair | Continues |
| Manual compaction | Can still be triggered with compact |
Impact Assessment
Section titled “Impact Assessment”Immediate Effects
Section titled “Immediate Effects”| Aspect | Impact |
|---|---|
| Compaction I/O | Stops (after current completes) |
| CPU from compaction | Reduces |
| New compaction tasks | None scheduled |
Accumulating Effects Over Time
Section titled “Accumulating Effects Over Time”| Duration | Impact |
|---|---|
| Minutes | Minimal impact |
| Hours | SSTable count begins growing |
| Days | Noticeable read performance degradation |
| Weeks | Severe performance issues, high SSTable counts |
SSTable Proliferation
Without compaction, each memtable flush creates a new SSTable. For write-heavy workloads, this can mean hundreds or thousands of SSTables accumulating quickly.
Performance Degradation Indicators
Section titled “Performance Degradation Indicators”| Metric | Normal | After Extended Disable |
|---|---|---|
| SSTable count per table | 4-20 (LCS) / varies (STCS) | 100+ |
| Read latency p99 | < 50ms | 200ms+ |
| Bloom filter memory | Normal | Elevated |
| Partition index memory | Normal | Elevated |
Workflow: Controlled Bulk Load
Section titled “Workflow: Controlled Bulk Load”#!/bin/bashKEYSPACE="my_keyspace"TABLE="my_table"DATA_DIR="/data/to/load"
echo "=== Pre-Load Checks ==="echo "SSTable count before:"nodetool tablestats $KEYSPACE.$TABLE | grep "SSTable count"
echo ""echo "=== Disabling Auto-Compaction ==="nodetool disableautocompaction $KEYSPACE $TABLE
echo "Verifying disabled:"nodetool statusautocompaction $KEYSPACE $TABLE
echo ""echo "=== Loading Data ==="# Your data loading method heresstableloader -d localhost $DATA_DIR/$KEYSPACE/$TABLE
echo ""echo "=== Post-Load ==="echo "SSTable count after load:"nodetool tablestats $KEYSPACE.$TABLE | grep "SSTable count"
echo ""echo "=== Re-enabling Auto-Compaction ==="nodetool enableautocompaction $KEYSPACE $TABLE
echo ""echo "=== Triggering Major Compaction ==="nodetool compact $KEYSPACE $TABLE
echo ""echo "=== Final SSTable Count ==="nodetool tablestats $KEYSPACE.$TABLE | grep "SSTable count"Monitoring While Disabled
Section titled “Monitoring While Disabled”Track SSTable Growth
Section titled “Track SSTable Growth”# Check SSTable count periodicallywatch -n 60 'nodetool tablestats my_keyspace.my_table | grep "SSTable count"'Monitor Read Performance
Section titled “Monitor Read Performance”# Watch read latencieswatch -n 10 'nodetool tablehistograms my_keyspace my_table | head -20'Check Compaction Status
Section titled “Check Compaction Status”# Verify still disablednodetool statusautocompaction my_keyspace my_tableSet Reminders
Section titled “Set Reminders”# Create a reminder to re-enableecho "nodetool enableautocompaction my_keyspace my_table" | at now + 2 hoursRisks and Mitigations
Section titled “Risks and Mitigations”Risk: Forgot to Re-enable
Section titled “Risk: Forgot to Re-enable”Symptom: Degraded read performance, high SSTable counts
Mitigation:
# Check all tables for disabled auto-compactionfor ks in $(nodetool tablestats | grep "Keyspace:" | awk '{print $2}'); do nodetool statusautocompaction $ks 2>/dev/null | grep "false"done
# Re-enable where needednodetool enableautocompactionRisk: Disk Space Exhaustion
Section titled “Risk: Disk Space Exhaustion”Symptom: No space left on device errors
Cause: Without compaction, tombstones aren't purged, deleted data isn't reclaimed
Mitigation:
# Check disk usagedf -h /var/lib/cassandra
# Clear snapshotsnodetool clearsnapshot --all
# Re-enable compaction immediatelynodetool enableautocompaction
# May need to reduce throughput if space is criticalnodetool setcompactionthroughput 16Risk: Tombstone Accumulation
Section titled “Risk: Tombstone Accumulation”Symptom: Read timeouts, TombstoneOverwhelmingException
Mitigation:
# Re-enable compactionnodetool enableautocompaction my_keyspace my_table
# Run garbagecollect to specifically target tombstonesnodetool garbagecollect my_keyspace my_tableTroubleshooting
Section titled “Troubleshooting”Compaction Still Running After Disable
Section titled “Compaction Still Running After Disable”Currently active compactions complete; only new ones are prevented:
# Check active compactionsnodetool compactionstats
# Wait for completion or stop explicitlynodetool stop COMPACTIONCannot Disable (Command Fails)
Section titled “Cannot Disable (Command Fails)”# Check JMX connectivitynodetool info
# Verify keyspace/table namesnodetool tablestats my_keyspace.my_table
# Check logs for errorstail -100 /var/log/cassandra/system.log | grep -i compactionStatus Shows Enabled After Disable
Section titled “Status Shows Enabled After Disable”# Retry the commandnodetool disableautocompaction my_keyspace my_table
# Verify with specific tablenodetool statusautocompaction my_keyspace my_table
# If still enabled, check for typos in keyspace/table namesCluster-Wide Operations
Section titled “Cluster-Wide Operations”Disable on All Nodes
Section titled “Disable on All Nodes”#!/bin/bashKEYSPACE="my_keyspace"TABLE="my_table"
# Get list of node IPs from local nodetool statusnodes=$(nodetool status | grep "^UN" | awk '{print $2}')
echo "Disabling auto-compaction cluster-wide..."for node in $nodes; do echo -n "$node: " ssh "$node" "nodetool disableautocompaction $KEYSPACE $TABLE && echo 'disabled' || echo 'FAILED'"done
echo ""echo "Verification:"for node in $nodes; do echo -n "$node: " ssh "$node" "nodetool statusautocompaction $KEYSPACE $TABLE 2>/dev/null"doneRecovery Procedure
Section titled “Recovery Procedure”If auto-compaction has been disabled too long:
#!/bin/bashecho "=== Compaction Recovery Procedure ==="
# 1. Check current stateecho "1. Current SSTable counts (top 10 highest):"nodetool tablestats | grep -E "Table:|SSTable count" | paste - - | sort -t: -k3 -nr | head -10
# 2. Check disk spaceecho ""echo "2. Disk space:"df -h /var/lib/cassandra
# 3. Re-enable auto-compactionecho ""echo "3. Re-enabling auto-compaction..."nodetool enableautocompaction
# 4. Reduce throughput to prevent overwhelming the systemecho ""echo "4. Setting conservative compaction throughput..."nodetool setcompactionthroughput 32
# 5. Monitorecho ""echo "5. Current compaction status:"nodetool compactionstats
echo ""echo "Monitor with: watch -n 5 'nodetool compactionstats'"echo "Increase throughput gradually: nodetool setcompactionthroughput 64"Best Practices
Section titled “Best Practices”Disable Guidelines
- Document the reason - Note why and when you disabled
- Set a reminder - Schedule re-enablement
- Monitor SSTable counts - Watch for accumulation
- Limit scope - Disable only specific tables, not entire cluster
- Limit duration - Keep disable period as short as possible
- Have a plan - Know when and how you'll re-enable
- Inform the team - Others should know compaction is disabled
Never Do
- Leave auto-compaction disabled in production for days
- Disable cluster-wide without a specific reason
- Forget to re-enable after maintenance
- Disable without monitoring SSTable growth
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| enableautocompaction | Re-enable auto-compaction |
| statusautocompaction | Check auto-compaction status |
| compact | Force manual compaction |
| compactionstats | View active compactions |
| stop | Stop running compactions |
| tablestats | View SSTable counts |
| garbagecollect | Remove tombstones |