Cassandra WriteTimeoutException Troubleshooting
Symptoms
Section titled “Symptoms”WriteTimeoutExceptionin application logs- Error message:
Cassandra timeout during SIMPLE write query - Client receives timeout error before operation completes
- Consistency level not achieved within timeout period
Error Message Examples
Section titled “Error Message Examples”com.datastax.driver.core.exceptions.WriteTimeoutException:Cassandra timeout during SIMPLE write query at consistency QUORUM(2 replicas were required but only 1 acknowledged the write)WriteTimeout: Error from server: code=1100 [Coordinator node timed out waitingfor replica nodes' responses] message="Operation timed out - received only1 responses." info={'received_responses': 1, 'required_responses': 2,'consistency': 'QUORUM', 'write_type': 'SIMPLE'}Common Causes
Section titled “Common Causes”1. Overloaded Nodes
Section titled “1. Overloaded Nodes”Replicas are too busy to process writes in time.
Diagnosis:
The coordinator raises WriteTimeoutException when replica acknowledgements do not arrive in time, and MutationStage on a node only processes mutations for the partitions that node replicates. A coordinator that does not replicate the affected partition therefore shows no MutationStage backlog while a replica is saturated. Identify the replicas first with nodetool getendpoints, as in Step 2: Check Cluster Status, then read the counters on each of those replicas rather than only on the node that returned the error.
# On each replica returned by nodetool getendpoints, not only the coordinator:
# Check MutationStage pendingnodetool tpstats | grep -E "Pool|Mutation"
# Check for dropped messagesnodetool tpstats | grep -E "MUTATION|Dropped"
# Sustained MutationStage pending indicates overloadThread Pools covers MutationStage and the other pools on the write path.
Resolution:
- Scale cluster (add nodes)
- Reduce write throughput
- Check for hot partitions
Establish what sits downstream of MutationStage before resizing it: commit log and memtable flush service time (Disk I/O Bottleneck), garbage collection pauses (GC Pauses), or a slow peer. Before resizing a stage maps each symptom to the command that settles it, and identifies the single case in which the pool size is the limit. Record the size in force with nodetool getconcurrency MutationStage before raising it, and set the recorded value again if the stage's pending count and the node's CPU utilization do not improve.
A runtime concurrency change is node-local and temporary
A resize takes effect on the node nodetool connects to and reaches no other replica, so the replicas behind one write can end up running MutationStage at different sizes. The value is stored in memory only, and the next start sizes the stage from concurrent_writes in cassandra.yaml again. Where the commit log and flush path are the constraint, a larger MutationStage sends more concurrent mutations to the same devices and deepens the backlog rather than draining it. Restart is not a usable rollback during an incident, so record the value in force before changing it.
2. Network Issues
Section titled “2. Network Issues”Network latency or partition between coordinator and replicas.
Diagnosis:
# Check network latencyping <replica_ip>
# Check gossip statenodetool gossipinfo | grep -A5 <replica_ip>
# Look for UnreachableMembersnodetool statusResolution:
- Fix network connectivity issues
- Check firewall rules (port 7000)
- Verify inter-node networking
3. Replica Node Down or Unresponsive
Section titled “3. Replica Node Down or Unresponsive”Not enough live replicas to satisfy consistency level.
Diagnosis:
# Check cluster statusnodetool status
# Look for Down (D) or unavailable nodes# Check if nodes are joining/leaving (J/L)Resolution:
- Bring down nodes back up
- Lower consistency level (if acceptable)
- Replace dead nodes
4. Disk I/O Bottleneck
Section titled “4. Disk I/O Bottleneck”Commit log writes are slow.
Diagnosis:
# Check disk I/Oiostat -xz 1 5
# Check commit log directory latency# Look for high await times
# Check for disk fulldf -h /var/lib/cassandraResolution:
- Use SSD/NVMe for commit log
- Separate commit log from data directory
- Increase disk capacity
5. Large Writes or Batches
Section titled “5. Large Writes or Batches”Individual writes or batches too large.
Diagnosis:
# Check for batch size warningsgrep -i "batch" /var/log/cassandra/system.log
# Check write sizes in table statsnodetool tablestats my_keyspace.table | grep -i writeResolution:
- Reduce batch sizes
- Split large writes into smaller operations
- Review data model for write amplification
6. GC Pauses
Section titled “6. GC Pauses”Long garbage collection pauses blocking writes.
Diagnosis:
# Check GC logstail -100 /var/log/cassandra/gc.log
# Pauses above the goal the collector was given. 300ms is what 5.0 sets for# -XX:MaxGCPauseMillis; under CMS on 4.1 and 4.0 there is no goal, so compare# against the baseline established for the node instead.grep -E "Pause (Young|Full)" /var/log/cassandra/gc.log \ | awk '{ d = $NF; sub(/ms$/, "", d); if (d + 0 > 300) print }' | tail -20Resolution:
The collector and its settings ship active on every release: G1 with a 300ms pause goal on 5.0, CMS on 4.1 and 4.0. Confirm from the GC log that collections are long enough to account for the timeout before changing anything, using GC Pause Issues, then change one setting at a time against a measured pause profile. Heap sizing and garbage collector settings per version identifies the collector each release ships and routes to its shipped values and what changing each one costs.
Write Types
Section titled “Write Types”The write_type in the error indicates what kind of write failed:
| Write Type | Description | Common Issues |
|---|---|---|
SIMPLE | Regular INSERT/UPDATE | Node overload, network |
BATCH | Batch operation | Batch too large, spanning partitions |
UNLOGGED_BATCH | Unlogged batch | Same as BATCH |
COUNTER | Counter update | Counter replica issues |
BATCH_LOG | Batch log write | Batch log nodes unavailable |
CAS | Lightweight transaction | Paxos timeout, contention |
VIEW | Materialized view | View replicas unavailable |
Step-by-Step Diagnosis
Section titled “Step-by-Step Diagnosis”Step 1: Check Write Type and Consistency Level
Section titled “Step 1: Check Write Type and Consistency Level”-- What was the query?-- Check consistency level requirementCONSISTENCY;
-- For QUORUM with RF=3, need 2 replicas-- For LOCAL_QUORUM with RF=3 in DC, need 2 in that DCStep 2: Check Cluster Status
Section titled “Step 2: Check Cluster Status”# Are all replicas up?nodetool status
# Check which nodes own the partitionnodetool getendpoints my_keyspace my_table <partition_key>Step 3: Check Node Health
Section titled “Step 3: Check Node Health”# On coordinator and replicas:
# Thread poolsnodetool tpstats
# Dropped messages (critical)nodetool tpstats | grep -E "Dropped|MUTATION"
# GC activitynodetool gcstats
# Recent errorstail -100 /var/log/cassandra/system.log | grep -i errorStep 4: Check Resource Utilization
Section titled “Step 4: Check Resource Utilization”# CPUtop -b -n 1 | head -20
# Memoryfree -h
# Disk I/Oiostat -xz 1 5
# Networksar -n DEV 1 5Step 5: Review Metrics
Section titled “Step 5: Review Metrics”# Write latencynodetool proxyhistograms
# Table-level write statsnodetool tablestats my_keyspace.table | grep -i writeResolution Strategies
Section titled “Resolution Strategies”Immediate Actions
Section titled “Immediate Actions”- Lower consistency level (temporary):
-- If eventual consistency is acceptableCONSISTENCY LOCAL_ONE;INSERT INTO table ...;- Increase timeout (application):
// Java driverSimpleStatement stmt = SimpleStatement.builder("INSERT ...") .setTimeout(Duration.ofSeconds(30)) .build();- Add retry logic (application):
RetryPolicy retry = new RetryPolicy() { @Override public RetryDecision onWriteTimeout(...) { if (writeType == WriteType.SIMPLE && retryCount < 3) { return RetryDecision.retry(cl); } return RetryDecision.rethrow(); }};Long-term Fixes
Section titled “Long-term Fixes”- Scale cluster:
# Add nodes to distribute load# Monitor: nodetool status during expansion- Tune concurrency and timeouts:
Validate a concurrency change on one node at runtime before writing it to a configuration file. Raise the stage only after the checks in Before resizing a stage show that the node is neither disk- nor CPU-bound, since MutationStage queues behind the commit log and flush path:
nodetool getconcurrency MutationStage # record the value in forcenodetool setconcurrency MutationStage 64 # applies to this node onlyAfter confirming a value helps on that node, persist it in cassandra.yaml and roll it out with the other write-path settings:
# Increase write timeoutwrite_request_timeout_in_ms: 10000 # default: 2000
# Persist a value already validated with nodetool setconcurrency aboveconcurrent_writes: 64 # default: 32
# Optimize commit logcommitlog_sync: periodiccommitlog_sync_period_in_ms: 10000- Review data model:
- Check for hot partitions
- Split large partitions
- Reduce write amplification
- Optimize hardware:
- Use NVMe for commit log
- Increase network bandwidth
- Add RAM for more memtable space
Prevention
Section titled “Prevention”Best Practices
Section titled “Best Practices”# Appropriate timeoutswrite_request_timeout_in_ms: 5000 # 5 seconds
# Thread pool sizing baseline, not a remedy for timeoutsconcurrent_writes: 32 # Based on disk count
# Proper sizing# memtable_heap_space_in_mb: adequate for workloadMonitoring
Section titled “Monitoring”# Alert on:- Write latency p99 > 1 second- Dropped MUTATION messages > 0- MutationStage pending > 100- Disk I/O await > 10msApplication Design
Section titled “Application Design”// Set appropriate timeoutsDriverConfigLoader loader = DriverConfigLoader.programmaticBuilder() .withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofSeconds(10)) .build();
// Use async writes for high throughputsession.executeAsync(statement);
// Implement proper error handlingtry { session.execute(statement);} catch (WriteTimeoutException e) { // Log and handle appropriately // Consider: retry, queue for later, alert}Related Issues
Section titled “Related Issues”- ReadTimeoutException - Read timeout troubleshooting
Next Steps
Section titled “Next Steps”- Thread Pools - What each pool does and what a backlog on one means
- Troubleshooting Guide - Additional troubleshooting guidance
- Monitoring Guide - Set up alerts