Monitors and controls SSTable merging in Apache Cassandra: inspects compactionstats and history, triggers manual merges, stops runaway operations, and selects or tunes strategies (STCS, LCS, TWCS) for table behavior.
Agentic Workflow: Read -> Reason -> Act (cassandra-compaction)
You are Cassandra Compaction (api/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — api context for cassandra-compaction
- Domain: Monitors and controls SSTable merging in Apache Cassandra: inspects compactionstats and history, triggers manual merges, stops runaway operations, and selects or tunes strategies (STCS, LCS, TWCS) for
- compaction-status: Inspect compaction activity and history. —
nodetool compactionstats
- manual-compaction: Trigger or stop compaction on tables. —
nodetool compact mykeyspace users
- strategy-tuning: Set and tune compaction strategies. —
cqlsh -e "ALTER TABLE mykeyspace.users WITH compaction = {'class':'LeveledCompac
- Check
knowledge and prerequisites: cqlsh, nodetool
2. Reason — think for cassandra-compaction
- For
compaction-status: Inspect compaction activity and history. — decide which checks to run
- For
manual-compaction: Trigger or stop compaction on tables. — decide which checks to run
- For
strategy-tuning: Set and tune compaction strategies. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with cassandra-compaction tools
- Tools:
Glob, Grep, Read, Nodetool, Cqlsh (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
cassandra-compaction:fae663f0
Cassandra Compaction
What this skill does
Manages Cassandra compaction: monitoring activity with compactionstats, triggering manual compactions, stopping runaway compaction, and selecting/tuning strategies (STCS/LCS/TWCS).
When to use
- Disk usage climbs due to many small SSTables
- Compaction is starving the cluster of I/O
- Choosing the right strategy for a table's workload
Real commands
# Monitor
nodetool compactionstats
nodetool compactionhistory | tail -20
# Manual compaction
nodetool compact mykeyspace users
# Stop runaway compaction
nodetool stop compaction
# Flush memtables first if needed
nodetool flush mykeyspace users
# Set strategy via cqlsh
cqlsh -e "ALTER TABLE mykeyspace.users WITH compaction = {'class':'LeveledCompactionStrategy','sstable_size_in_mb':160}"
# Throttle
nodetool setcompactionthroughput 64
Strategy guidance
- STCS: default; good for most workloads
- LCS: read-heavy, low-latency (better read amplification)
- TWCS: time-series with TTL data
Testing
- Check compactionhistory for completed runs after manual compact
- Watch pending tasks in compactionstats
Best practices
- Schedule major compactions in maintenance windows
- Throttle during peak traffic
- Use TWCS for time-series tables; never LCS+TWCS mix
Capabilities
compaction-status
Inspect compaction activity and history.
Parameters:
keyspace (string): Keyspace name
table (string): Table name
Commands:
nodetool compactionstats
nodetool compactionhistory
nodetool status
nodetool cfstats mykeyspace
nodetool tablestats mykeyspace.users
Examples:
- nodetool compactionstats
- nodetool compactionhistory | tail -20
- nodetool tablestats mykeyspace.users | grep -E 'SSTable|pending'
manual-compaction
Trigger or stop compaction on tables.
Parameters:
keyspace (string): Keyspace to compact
table (string): Table to compact
Commands:
nodetool compact mykeyspace users
nodetool compact -- mykeyspace users
nodetool stop compaction
nodetool scrub mykeyspace users
nodetool flush mykeyspace users
Examples:
- nodetool compact mykeyspace users
- nodetool stop compaction
- nodetool flush mykeyspace users
strategy-tuning
Set and tune compaction strategies.
Parameters:
strategy (string): STCS, LCS, TWCS
throughput (number): Compaction throughput MB/s
Commands:
cqlsh -e "ALTER TABLE mykeyspace.users WITH compaction = {'class':'LeveledCompactionStrategy','sstable_size_in_mb':160}"
cqlsh -e "SELECT table_name, compaction FROM system_schema.tables WHERE keyspace_name='mykeyspace'"
cqlsh -e "ALTER TABLE mykeyspace.users WITH compaction = {'class':'SizeTieredCompactionStrategy','min_threshold':4}"
nodetool getcompactionthroughput
nodetool setcompactionthroughput 64
Examples:
- cqlsh -e "ALTER TABLE mykeyspace.users WITH compaction = {'class':'LeveledCompactionStrategy','sstable_size_in_mb':160}"
- cqlsh -e "SELECT table_name, compaction FROM system_schema.tables WHERE keyspace_name='mykeyspace'"
- nodetool setcompactionthroughput 64
References
1---2name: "cassandra-compaction"3description: "Monitors and controls SSTable merging in Apache Cassandra: inspects compactionstats and history, triggers manual merges, stops runaway operations, and selects or tunes strategies (STCS, LCS, TWCS) for table behavior. Use when working with compaction status, manual compaction, strategy tuning, api or when the user mentions compaction status, manual compaction, strategy tuning, api."4license: "MIT"5compatibility: "Requires cqlsh, nodetool."6metadata:7 source: https://skillmd.com/skills/opknock/cassandra-compaction8 author: Kdesk9 version: 2.0.010 category: api11allowed-tools: "Glob Grep Read Bash(cqlsh:*) Bash(nodetool:*)"12---1314Monitors and controls SSTable merging in Apache Cassandra: inspects compactionstats and history, triggers manual merges, stops runaway operations, and selects or tunes strategies (STCS, LCS, TWCS) for table behavior.1516## Agentic Workflow: Read -> Reason -> Act (cassandra-compaction)1718You are **Cassandra Compaction** (api/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — api context for `cassandra-compaction`21- Domain: Monitors and controls SSTable merging in Apache Cassandra: inspects compactionstats and history, triggers manual merges, stops runaway operations, and selects or tunes strategies (STCS, LCS, TWCS) for22- **compaction-status**: Inspect compaction activity and history. — `nodetool compactionstats`23- **manual-compaction**: Trigger or stop compaction on tables. — `nodetool compact mykeyspace users`24- **strategy-tuning**: Set and tune compaction strategies. — `cqlsh -e "ALTER TABLE mykeyspace.users WITH compaction = {'class':'LeveledCompac`25- Check `knowledge` and `prerequisites: cqlsh, nodetool`2627### 2. Reason — think for `cassandra-compaction`28- For `compaction-status`: Inspect compaction activity and history. — decide which checks to run29- For `manual-compaction`: Trigger or stop compaction on tables. — decide which checks to run30- For `strategy-tuning`: Set and tune compaction strategies. — decide which checks to run31- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3233### 3. Act — execute with `cassandra-compaction` tools34- Tools: `Glob`, `Grep`, `Read`, `Nodetool`, `Cqlsh` (see frontmatter `tools`/`allowed-tools`)35- Use `safe_path` for any write; record evidence (paths, checksums)36- Fingerprint: `cassandra-compaction:fae663f0`3738# Cassandra Compaction3940## What this skill does4142Manages Cassandra compaction: monitoring activity with compactionstats, triggering manual compactions, stopping runaway compaction, and selecting/tuning strategies (STCS/LCS/TWCS).4344## When to use4546- Disk usage climbs due to many small SSTables47- Compaction is starving the cluster of I/O48- Choosing the right strategy for a table's workload4950## Real commands5152```bash53# Monitor54nodetool compactionstats55nodetool compactionhistory | tail -205657# Manual compaction58nodetool compact mykeyspace users5960# Stop runaway compaction61nodetool stop compaction6263# Flush memtables first if needed64nodetool flush mykeyspace users6566# Set strategy via cqlsh67cqlsh -e "ALTER TABLE mykeyspace.users WITH compaction = {'class':'LeveledCompactionStrategy','sstable_size_in_mb':160}"6869# Throttle70nodetool setcompactionthroughput 6471```7273## Strategy guidance7475- STCS: default; good for most workloads76- LCS: read-heavy, low-latency (better read amplification)77- TWCS: time-series with TTL data7879## Testing8081- Check compactionhistory for completed runs after manual compact82- Watch pending tasks in compactionstats8384## Best practices8586- Schedule major compactions in maintenance windows87- Throttle during peak traffic88- Use TWCS for time-series tables; never LCS+TWCS mix8990## Capabilities9192### compaction-status93Inspect compaction activity and history.9495**Parameters:**96- `keyspace` (string): Keyspace name97- `table` (string): Table name9899**Commands:**100- `nodetool compactionstats`101- `nodetool compactionhistory`102- `nodetool status`103- `nodetool cfstats mykeyspace`104- `nodetool tablestats mykeyspace.users`105106**Examples:**107- nodetool compactionstats108- nodetool compactionhistory | tail -20109- nodetool tablestats mykeyspace.users | grep -E 'SSTable|pending'110111### manual-compaction112Trigger or stop compaction on tables.113114**Parameters:**115- `keyspace` (string): Keyspace to compact116- `table` (string): Table to compact117118**Commands:**119- `nodetool compact mykeyspace users`120- `nodetool compact -- mykeyspace users`121- `nodetool stop compaction`122- `nodetool scrub mykeyspace users`123- `nodetool flush mykeyspace users`124125**Examples:**126- nodetool compact mykeyspace users127- nodetool stop compaction128- nodetool flush mykeyspace users129130### strategy-tuning131Set and tune compaction strategies.132133**Parameters:**134- `strategy` (string): STCS, LCS, TWCS135- `throughput` (number): Compaction throughput MB/s136137**Commands:**138- `cqlsh -e "ALTER TABLE mykeyspace.users WITH compaction = {'class':'LeveledCompactionStrategy','sstable_size_in_mb':160}"`139- `cqlsh -e "SELECT table_name, compaction FROM system_schema.tables WHERE keyspace_name='mykeyspace'"`140- `cqlsh -e "ALTER TABLE mykeyspace.users WITH compaction = {'class':'SizeTieredCompactionStrategy','min_threshold':4}"`141- `nodetool getcompactionthroughput`142- `nodetool setcompactionthroughput 64`143144**Examples:**145- cqlsh -e "ALTER TABLE mykeyspace.users WITH compaction = {'class':'LeveledCompactionStrategy','sstable_size_in_mb':160}"146- cqlsh -e "SELECT table_name, compaction FROM system_schema.tables WHERE keyspace_name='mykeyspace'"147- nodetool setcompactionthroughput 64148149## References150- [Cassandra Compaction](https://cassandra.apache.org/doc/latest/cassandra/operating/compaction/index.html)151- [nodetool Reference](https://cassandra.apache.org/doc/latest/cassandra/operating/nodetool/)