What's Actually Happening
Cassandra compaction is stuck or running too slowly, affecting performance and disk space.
The Error You'll See
```bash $ nodetool compactionstats
pending tasks: 50 compaction type keyspace table completed total unit progress Major myks mytable 50000000 100000000 bytes 50.00% id: 12345 ```
Why This Happens
- 1.Large SSTables - Too much data to compact
- 2.Insufficient disk space - Not enough room for compaction
- 3.Compaction throughput too low - Rate limiting too aggressive
- 4.Too many pending compactions - Queue overflow
Step 1: Check Compaction Status
```bash # Check compaction stats: nodetool compactionstats
# Check pending compactions: nodetool cfstats myks | grep "Pending compactions"
# Check disk space: df -h /var/lib/cassandra ```
Step 2: Increase Compaction Throughput
```bash # Check current setting: nodetool getcompactionthroughput
# Increase throughput: nodetool setcompactionthroughput 64 ```
Step 3: Free Disk Space
```bash # Run cleanup: nodetool cleanup
# Or truncate unwanted data: # Check tombstones: nodetool cfstats myks | grep "Tombstones" ```
Step 4: Adjust Compaction Strategy
-- Change compaction strategy:
ALTER TABLE myks.mytable WITH compaction = {
'class': 'SizeTieredCompactionStrategy',
'enabled': true
};Cassandra Compaction Checklist
| Check | Command | Expected |
|---|---|---|
| Compaction stats | nodetool | Progressing |
| Disk space | df -h | Available |
| Throughput | getcompactionthroughput | Adequate |
Verify the Fix
nodetool compactionstats
# Output: pending tasks: 0Related Issues
- [Fix Cassandra Nodes Down](/articles/fix-cassandra-nodes-down)
- [Fix Cassandra Query Timeout](/articles/fix-cassandra-query-timeout)