nodetool repair
Runs anti-entropy repair to synchronize data across replicas, ensuring consistency and preventing data resurrection from expired tombstones.
Synopsis
Section titled “Synopsis”nodetool [connection_options] repair [options] [--] [keyspace [table ...]]See connection options for connection options.
Description
Section titled “Description”nodetool repair compares data between replica nodes using Merkle trees and streams any differences to ensure all replicas hold identical data. Repair is essential for:
- Maintaining data consistency
- Preventing tombstone resurrection (zombie data)
- Recovering from node failures or network partitions
Comprehensive Repair Documentation
For detailed repair concepts, strategies, and scheduling guidance, see:
- Repair Concepts - How repair works
- Repair Options Reference - All options explained
- Repair Strategies - Implementation approaches
- Repair Scheduling - Planning repair cycles
Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
keyspace | Keyspace to repair. Required for targeted repairs |
table | Specific table(s) to repair. If omitted, repairs all tables |
Key Options
Section titled “Key Options”| Option | Description |
|---|---|
-pr, --partitioner-range | Repair only primary range (recommended) |
--full | Full repair instead of incremental |
-seq, --sequential | Repair one node at a time |
-dcpar, --dc-parallel | Parallel within DC, sequential across DCs |
-dc, --in-dc | Repair only within specified datacenter(s) |
-local, --in-local-dc | Repair only within local datacenter |
-st, --start-token | Start token for repair range |
-et, --end-token | End token for repair range |
-j, --job-threads | Number of repair job threads |
Common Usage Patterns
Section titled “Common Usage Patterns”Primary Range Repair (Recommended)
Section titled “Primary Range Repair (Recommended)”nodetool repair -pr my_keyspaceAlways Use -pr
Without -pr, each node repairs all ranges it holds (primary + replica), causing redundant work. With -pr, run repair on every node to cover all ranges exactly once.
Full vs Incremental Repair
Section titled “Full vs Incremental Repair”# Full repair (default before 4.0)nodetool repair --full -pr my_keyspace
# Incremental repair (default in 4.0+)nodetool repair -pr my_keyspace| Type | Behavior | Use Case |
|---|---|---|
| Full | Repairs all data | Recovery, initial sync |
| Incremental | Repairs only unrepaired data | Regular maintenance |
Local Datacenter Only
Section titled “Local Datacenter Only”nodetool repair -pr -local my_keyspaceRepairs only with replicas in the same datacenter.
Specific Token Range
Section titled “Specific Token Range”nodetool repair -pr -st 0 -et 1000000000 my_keyspaceRepairs only the specified token range (subrange repair).
When to Use
Section titled “When to Use”Routine Maintenance
Section titled “Routine Maintenance”gc_grace_seconds Constraint
Repair must complete on all nodes within gc_grace_seconds (default 10 days) to prevent tombstone resurrection.
# Run on each nodenodetool repair -pr my_keyspaceAfter Node Recovery
Section titled “After Node Recovery”After a node was down for extended time:
nodetool repair -pr my_keyspaceAfter Network Partition
Section titled “After Network Partition”If nodes were isolated:
nodetool repair -pr my_keyspaceBefore Major Version Upgrade
Section titled “Before Major Version Upgrade”Ensure consistency before upgrading:
nodetool repair --full my_keyspaceWhen NOT to Use
Section titled “When NOT to Use”Repair Considerations
Avoid repair:
- During high traffic - Significant resource impact
- While streaming - Interferes with bootstrap/decommission
- With down nodes - Repair will fail or skip ranges
- Immediately after bulk load - Wait for compaction
Impact Analysis
Section titled “Impact Analysis”Resource Usage
Section titled “Resource Usage”| Resource | Impact |
|---|---|
| Network | High - streams data between nodes |
| Disk I/O | High - reads SSTables, writes repairs |
| CPU | Moderate - Merkle tree calculation |
| Memory | Merkle trees require heap space |
Performance Impact
Section titled “Performance Impact”During repair, the following operations impact cluster performance:
| Operation | Description |
|---|---|
| Merkle Tree Build | Computes hash trees for data comparison |
| Data Comparison | Compares trees between replicas |
| Data Streaming | Streams differing data between nodes |
Expected impact during repair:
| Metric | Impact |
|---|---|
| Read latency | +10-30% |
| Write latency | +5-15% |
| Network utilization | +20-50% |
Monitoring Repair
Section titled “Monitoring Repair”Check Active Repairs
Section titled “Check Active Repairs”nodetool repair_admin listShows running repair sessions.
Monitor Progress
Section titled “Monitor Progress”nodetool netstatsShows streaming activity from repair.
Check Repair History
Section titled “Check Repair History”nodetool repair_admin list --allShows completed and failed repairs.
Abort Repair
Section titled “Abort Repair”nodetool repair_admin cancel <repair_id>Canceling Repair
Canceled repairs leave data partially synchronized. Restart repair to complete synchronization.
Examples
Section titled “Examples”Standard Maintenance Repair
Section titled “Standard Maintenance Repair”# Run on each node sequentiallynodetool repair -pr my_keyspaceRepair Specific Table
Section titled “Repair Specific Table”nodetool repair -pr my_keyspace usersParallel Repair (Faster)
Section titled “Parallel Repair (Faster)”nodetool repair -pr --parallel my_keyspaceMulti-DC Repair
Section titled “Multi-DC Repair”# Repair with all DCsnodetool repair -pr my_keyspace
# Repair specific DCs onlynodetool repair -pr -dc dc1 -dc dc2 my_keyspaceVerbose Output
Section titled “Verbose Output”nodetool repair -pr --trace my_keyspaceCommon Issues
Section titled “Common Issues”Repair Fails with Timeout
Section titled “Repair Fails with Timeout”ERROR: Repair failed with error: Repair job timed outSolutions:
- Reduce repair scope (single table)
- Use subrange repair
- Increase
streaming_socket_timeout_in_ms
Repair Session Already Running
Section titled “Repair Session Already Running”ERROR: Repair session already in progressCheck and wait for existing repair:
nodetool repair_admin listOut of Memory
Section titled “Out of Memory”ERROR: java.lang.OutOfMemoryError: Java heap spaceMerkle trees consume heap. Solutions:
- Reduce repair parallelism
- Increase heap size
- Use subrange repair
Inconsistent Data After Repair
Section titled “Inconsistent Data After Repair”If data still appears inconsistent:
- Verify repair completed successfully
- Check all nodes were repaired
- Run
nodetool repair --fullfor complete sync
Best Practices
Section titled “Best Practices”Repair Guidelines
- Use -pr flag - Prevents redundant work
- Complete within gc_grace_seconds - Prevent zombies
- One node at a time - For sequential strategy
- Off-peak hours - Minimize production impact
- Monitor progress - Watch for failures
- Automate - Use AxonOps for scheduling
Repair Schedule Example
Section titled “Repair Schedule Example”| Cluster Size | Strategy | Frequency |
|---|---|---|
| 3-6 nodes | Sequential | Weekly |
| 6-20 nodes | Parallel | Every 3-5 days |
| 20-50 nodes | DC-parallel | Every 2-3 days |
| 50+ nodes | Continuous (AxonOps) | Always running |
Related Commands
Section titled “Related Commands”| Command | Relationship |
|---|---|
| repair_admin | Manage repair sessions |
| netstats | Monitor streaming |
| status | Check node states before repair |
| scrub | Fix local SSTable corruption |