Cassandra Repair Failures
Repairs synchronize data across replicas to ensure consistency. Repair failures leave data inconsistent and can lead to read inconsistencies.
Symptoms
Section titled “Symptoms”nodetool repairexits with errors- Repairs hang indefinitely
- "Repair session failed" in logs
- Incremental repair streams failing
- Long-running repairs that never complete
- OOM during repair
Diagnosis
Section titled “Diagnosis”Step 1: Check Active Repairs
Section titled “Step 1: Check Active Repairs”nodetool repair_admin listStep 2: Check Repair History
Section titled “Step 2: Check Repair History”# View recent repairscqlsh -e "SELECT * FROM system_distributed.repair_history LIMIT 20;"
# Check parent repair sessionscqlsh -e "SELECT * FROM system_distributed.parent_repair_history LIMIT 10;"Step 3: Check Logs for Errors
Section titled “Step 3: Check Logs for Errors”grep -i "repair\|streaming\|merkle" /var/log/cassandra/system.log | tail -100Common error patterns:
Repair session failedSync failed betweenStreaming errorOutOfMemoryError during repair
Step 4: Check Resource Usage
Section titled “Step 4: Check Resource Usage”# During repairtop -p $(pgrep -f CassandraDaemon)iostat -x 1 5df -h /var/lib/cassandraStep 5: Check Stream Throughput
Section titled “Step 5: Check Stream Throughput”nodetool netstatsResolution
Section titled “Resolution”Case 1: Repair Session Stuck
Section titled “Case 1: Repair Session Stuck”Cancel and restart:
# List active repairsnodetool repair_admin list
# Cancel stuck repairnodetool repair_admin cancel <repair-id>
# Or cancel all repairs on nodenodetool repair_admin cancel --force
# Restart with smaller scopenodetool repair -pr my_keyspace my_tableCase 2: OOM During Repair
Section titled “Case 2: OOM During Repair”Reduce repair scope:
# Repair one table at a timenodetool repair -pr my_keyspace table1nodetool repair -pr my_keyspace table2
# Use subrange repair for large tablesnodetool repair -pr -st <start_token> -et <end_token> my_keyspaceAdjust memory settings:
# In cassandra.yaml (4.1+ syntax)# Reduce repair memory usagerepair_session_space: 256MiBconcurrent_merkle_tree_requests: 2Case 3: Streaming Failures
Section titled “Case 3: Streaming Failures”Check network:
# Verify streaming portsnc -zv <peer-node> 7000
# Check streaming throughput limitnodetool getstreamthroughputIncrease timeouts:
streaming_socket_timeout_in_ms: 86400000 # 24 hoursstreaming_keep_alive_period_in_secs: 300Case 4: Repair Taking Too Long
Section titled “Case 4: Repair Taking Too Long”Use parallel repair:
# Parallel repair (Cassandra 4.0+)nodetool repair -pr --parallel my_keyspaceIncrease stream throughput:
# Check current settingnodetool getstreamthroughput
# Increase if network allows (value in Mb/s by default)nodetool setstreamthroughput 400
# Or specify MiB/s explicitly with -m flagnodetool setstreamthroughput -m 50 # 50 MiB/sSchedule repairs by token range:
#!/bin/bash# Repair in smaller chunksranges=$(nodetool describering my_keyspace | grep TokenRange | head -10)for range in $ranges; do start=$(echo $range | cut -d'(' -f2 | cut -d',' -f1) end=$(echo $range | cut -d',' -f2 | cut -d')' -f1) nodetool repair -st $start -et $end my_keyspacedoneCase 5: Incremental Repair Issues
Section titled “Case 5: Incremental Repair Issues”Switch to full repair:
# Full repair instead of incrementalnodetool repair -full -pr my_keyspaceReset repair state:
# Mark SSTables as unrepaired (use with caution)nodetool repair_admin cancel --forcesstablerepairedset --really-set --is-unrepaired /var/lib/cassandra/data/my_keyspace/my_table-*/*.dbCase 6: Schema Disagreement Blocking Repair
Section titled “Case 6: Schema Disagreement Blocking Repair”# Check schemanodetool describecluster
# Fix schema disagreement first (see schema-disagreement.md)nodetool reloadlocalschema
# Then retry repairnodetool repair -pr my_keyspaceRecovery
Section titled “Recovery”Verify Repair Completion
Section titled “Verify Repair Completion”# Check repair historycqlsh -e "SELECT * FROM system_distributed.repair_history WHERE keyspace_name = 'my_keyspace' LIMIT 5;"
# Verify no pending repairsnodetool repair_admin listVerify Data Consistency
Section titled “Verify Data Consistency”# Run read repair on critical datacqlsh -e "SELECT * FROM my_keyspace.my_table WHERE ... ;"# With consistency ALL to force read repairRepair Best Practices
Section titled “Repair Best Practices”Scheduling
Section titled “Scheduling”| Cluster Size | Repair Frequency | Strategy |
|---|---|---|
| < 10 nodes | Weekly | Full cluster repair |
| 10-50 nodes | Weekly per node | Rolling repair |
| > 50 nodes | Sub-range daily | Token range repair |
Command Options
Section titled “Command Options”# Primary range only (most common)nodetool repair -pr my_keyspace
# Full repair (vs incremental)nodetool repair -full -pr my_keyspace
# Specific tablesnodetool repair -pr my_keyspace table1 table2
# Parallel (Cassandra 4.0+)nodetool repair -pr --parallel my_keyspace
# Local datacenter onlynodetool repair -pr -local my_keyspaceResource Management
Section titled “Resource Management”# cassandra.yaml - repair settings (4.1+ syntax)repair_session_space: 256MiBconcurrent_merkle_tree_requests: 2
# Limit repair impact (4.1+ syntax)compaction_throughput: 64MiB/sstream_throughput_outbound: 24MiB/sSetting Name Changes
| Setting | Pre-4.1 | 4.1+ |
|---|---|---|
| Compaction throughput | compaction_throughput_mb_per_sec | compaction_throughput (with units) |
| Stream throughput | stream_throughput_outbound_megabits_per_sec | stream_throughput_outbound (MiB/s) |
| Repair session space | repair_session_space_in_mb | repair_session_space (with units) |
Prevention
Section titled “Prevention”- Schedule regular repairs - Run before gc_grace_seconds expires
- Monitor repair duration - Alert if repairs take > 24 hours
- Size partitions appropriately - Large partitions cause OOM during repair
- Maintain cluster health - Repair requires all replicas available
- Use repair tools - Consider Reaper for automated repair scheduling
Related Commands
Section titled “Related Commands”| Command | Purpose |
|---|---|
nodetool repair | Run repair |
nodetool repair_admin list | List active repairs |
nodetool repair_admin cancel | Cancel repair |
nodetool netstats | Check streaming status |
nodetool setstreamthroughput | Adjust stream speed |
Related Documentation
Section titled “Related Documentation”- Repair Operations - Repair concepts and procedures
- Schema Disagreement - Schema issues affecting repair