Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

nodetool disableautocompaction

Disables automatic compaction for specified keyspaces and tables.


Terminal window
nodetool [connection_options] disableautocompaction [--] [<keyspace> <tables>...]

See connection options for connection options.

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_table
WITH 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.


ArgumentDescription
keyspaceTarget keyspace name. If omitted, applies to all keyspaces
tablesSpace-separated list of table names. If omitted, applies to all tables in the keyspace

Terminal window
# Disable compaction on all tables (use carefully!)
nodetool disableautocompaction
Terminal window
# Disable for all tables in a keyspace
nodetool disableautocompaction my_keyspace
Terminal window
# Disable for specific tables only
nodetool disableautocompaction my_keyspace users orders
Terminal window
# Disable and verify
nodetool disableautocompaction my_keyspace my_table
nodetool statusautocompaction my_keyspace my_table
# Expected: running=false

Disable compaction to avoid overhead during large imports:

Terminal window
# 1. Disable auto-compaction
nodetool disableautocompaction my_keyspace my_table
# 2. Load data using sstableloader
sstableloader -d node1,node2,node3 /path/to/sstables/
# 3. Re-enable after load completes
nodetool enableautocompaction my_keyspace my_table
# 4. Force major compaction to consolidate
nodetool compact my_keyspace my_table

Isolate compaction when investigating performance issues:

Terminal window
# Stop compaction to see if it's the cause
nodetool disableautocompaction my_keyspace
# Monitor system behavior
# ...
# Re-enable when done
nodetool enableautocompaction my_keyspace

Some administrators disable during repair to reduce I/O contention:

Terminal window
# Disable compaction
nodetool disableautocompaction my_keyspace
# Run repair
nodetool repair -pr my_keyspace
# Re-enable compaction
nodetool enableautocompaction my_keyspace

Temporarily halt compaction when disk is critically full:

Terminal window
# Stop compaction (prevents additional space usage)
nodetool disableautocompaction
# Free space
nodetool clearsnapshot --all
rm -rf /var/lib/cassandra/data/*/*/backups/*
# Re-enable carefully
nodetool enableautocompaction

  1. No new compaction tasks are scheduled for the table
  2. Currently running compactions complete normally
  3. SSTables accumulate without merging
  4. Tombstones are not purged through compaction
  5. Disk space is not reclaimed from deleted data
FeatureStatus
ReadsContinue (but may slow down)
WritesContinue normally
Memtable flushesContinue creating new SSTables
StreamingContinues
RepairContinues
Manual compactionCan still be triggered with compact

AspectImpact
Compaction I/OStops (after current completes)
CPU from compactionReduces
New compaction tasksNone scheduled
DurationImpact
MinutesMinimal impact
HoursSSTable count begins growing
DaysNoticeable read performance degradation
WeeksSevere 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.

MetricNormalAfter Extended Disable
SSTable count per table4-20 (LCS) / varies (STCS)100+
Read latency p99< 50ms200ms+
Bloom filter memoryNormalElevated
Partition index memoryNormalElevated

bulk_load_controlled.sh
#!/bin/bash
KEYSPACE="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 here
sstableloader -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"

Terminal window
# Check SSTable count periodically
watch -n 60 'nodetool tablestats my_keyspace.my_table | grep "SSTable count"'
Terminal window
# Watch read latencies
watch -n 10 'nodetool tablehistograms my_keyspace my_table | head -20'
Terminal window
# Verify still disabled
nodetool statusautocompaction my_keyspace my_table
Terminal window
# Create a reminder to re-enable
echo "nodetool enableautocompaction my_keyspace my_table" | at now + 2 hours

Symptom: Degraded read performance, high SSTable counts

Mitigation:

Terminal window
# Check all tables for disabled auto-compaction
for ks in $(nodetool tablestats | grep "Keyspace:" | awk '{print $2}'); do
nodetool statusautocompaction $ks 2>/dev/null | grep "false"
done
# Re-enable where needed
nodetool enableautocompaction

Symptom: No space left on device errors

Cause: Without compaction, tombstones aren't purged, deleted data isn't reclaimed

Mitigation:

Terminal window
# Check disk usage
df -h /var/lib/cassandra
# Clear snapshots
nodetool clearsnapshot --all
# Re-enable compaction immediately
nodetool enableautocompaction
# May need to reduce throughput if space is critical
nodetool setcompactionthroughput 16

Symptom: Read timeouts, TombstoneOverwhelmingException

Mitigation:

Terminal window
# Re-enable compaction
nodetool enableautocompaction my_keyspace my_table
# Run garbagecollect to specifically target tombstones
nodetool garbagecollect my_keyspace my_table

Currently active compactions complete; only new ones are prevented:

Terminal window
# Check active compactions
nodetool compactionstats
# Wait for completion or stop explicitly
nodetool stop COMPACTION
Terminal window
# Check JMX connectivity
nodetool info
# Verify keyspace/table names
nodetool tablestats my_keyspace.my_table
# Check logs for errors
tail -100 /var/log/cassandra/system.log | grep -i compaction
Terminal window
# Retry the command
nodetool disableautocompaction my_keyspace my_table
# Verify with specific table
nodetool statusautocompaction my_keyspace my_table
# If still enabled, check for typos in keyspace/table names

disable_autocompaction_cluster.sh
#!/bin/bash
KEYSPACE="my_keyspace"
TABLE="my_table"
# Get list of node IPs from local nodetool status
nodes=$(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"
done

If auto-compaction has been disabled too long:

recover_from_disabled_compaction.sh
#!/bin/bash
echo "=== Compaction Recovery Procedure ==="
# 1. Check current state
echo "1. Current SSTable counts (top 10 highest):"
nodetool tablestats | grep -E "Table:|SSTable count" | paste - - | sort -t: -k3 -nr | head -10
# 2. Check disk space
echo ""
echo "2. Disk space:"
df -h /var/lib/cassandra
# 3. Re-enable auto-compaction
echo ""
echo "3. Re-enabling auto-compaction..."
nodetool enableautocompaction
# 4. Reduce throughput to prevent overwhelming the system
echo ""
echo "4. Setting conservative compaction throughput..."
nodetool setcompactionthroughput 32
# 5. Monitor
echo ""
echo "5. Current compaction status:"
nodetool compactionstats
echo ""
echo "Monitor with: watch -n 5 'nodetool compactionstats'"
echo "Increase throughput gradually: nodetool setcompactionthroughput 64"

Disable Guidelines

  1. Document the reason - Note why and when you disabled
  2. Set a reminder - Schedule re-enablement
  3. Monitor SSTable counts - Watch for accumulation
  4. Limit scope - Disable only specific tables, not entire cluster
  5. Limit duration - Keep disable period as short as possible
  6. Have a plan - Know when and how you'll re-enable
  7. 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

CommandRelationship
enableautocompactionRe-enable auto-compaction
statusautocompactionCheck auto-compaction status
compactForce manual compaction
compactionstatsView active compactions
stopStop running compactions
tablestatsView SSTable counts
garbagecollectRemove tombstones