Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

Cassandra WriteTimeoutException Troubleshooting

  • WriteTimeoutException in application logs
  • Error message: Cassandra timeout during SIMPLE write query
  • Client receives timeout error before operation completes
  • Consistency level not achieved within timeout period
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 waiting
for replica nodes' responses] message="Operation timed out - received only
1 responses." info={'received_responses': 1, 'required_responses': 2,
'consistency': 'QUORUM', 'write_type': 'SIMPLE'}

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.

Terminal window
# On each replica returned by nodetool getendpoints, not only the coordinator:
# Check MutationStage pending
nodetool tpstats | grep -E "Pool|Mutation"
# Check for dropped messages
nodetool tpstats | grep -E "MUTATION|Dropped"
# Sustained MutationStage pending indicates overload

Thread 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.

Network latency or partition between coordinator and replicas.

Diagnosis:

Terminal window
# Check network latency
ping <replica_ip>
# Check gossip state
nodetool gossipinfo | grep -A5 <replica_ip>
# Look for UnreachableMembers
nodetool status

Resolution:

  • Fix network connectivity issues
  • Check firewall rules (port 7000)
  • Verify inter-node networking

Not enough live replicas to satisfy consistency level.

Diagnosis:

Terminal window
# Check cluster status
nodetool 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

Commit log writes are slow.

Diagnosis:

Terminal window
# Check disk I/O
iostat -xz 1 5
# Check commit log directory latency
# Look for high await times
# Check for disk full
df -h /var/lib/cassandra

Resolution:

  • Use SSD/NVMe for commit log
  • Separate commit log from data directory
  • Increase disk capacity

Individual writes or batches too large.

Diagnosis:

Terminal window
# Check for batch size warnings
grep -i "batch" /var/log/cassandra/system.log
# Check write sizes in table stats
nodetool tablestats my_keyspace.table | grep -i write

Resolution:

  • Reduce batch sizes
  • Split large writes into smaller operations
  • Review data model for write amplification

Long garbage collection pauses blocking writes.

Diagnosis:

Terminal window
# Check GC logs
tail -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 -20

Resolution:

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.


The write_type in the error indicates what kind of write failed:

Write TypeDescriptionCommon Issues
SIMPLERegular INSERT/UPDATENode overload, network
BATCHBatch operationBatch too large, spanning partitions
UNLOGGED_BATCHUnlogged batchSame as BATCH
COUNTERCounter updateCounter replica issues
BATCH_LOGBatch log writeBatch log nodes unavailable
CASLightweight transactionPaxos timeout, contention
VIEWMaterialized viewView replicas unavailable

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 requirement
CONSISTENCY;
-- For QUORUM with RF=3, need 2 replicas
-- For LOCAL_QUORUM with RF=3 in DC, need 2 in that DC
Terminal window
# Are all replicas up?
nodetool status
# Check which nodes own the partition
nodetool getendpoints my_keyspace my_table <partition_key>
Terminal window
# On coordinator and replicas:
# Thread pools
nodetool tpstats
# Dropped messages (critical)
nodetool tpstats | grep -E "Dropped|MUTATION"
# GC activity
nodetool gcstats
# Recent errors
tail -100 /var/log/cassandra/system.log | grep -i error
Terminal window
# CPU
top -b -n 1 | head -20
# Memory
free -h
# Disk I/O
iostat -xz 1 5
# Network
sar -n DEV 1 5
Terminal window
# Write latency
nodetool proxyhistograms
# Table-level write stats
nodetool tablestats my_keyspace.table | grep -i write

  1. Lower consistency level (temporary):
-- If eventual consistency is acceptable
CONSISTENCY LOCAL_ONE;
INSERT INTO table ...;
  1. Increase timeout (application):
// Java driver
SimpleStatement stmt = SimpleStatement.builder("INSERT ...")
.setTimeout(Duration.ofSeconds(30))
.build();
  1. 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();
}
};
  1. Scale cluster:
Terminal window
# Add nodes to distribute load
# Monitor: nodetool status during expansion
  1. 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:

Terminal window
nodetool getconcurrency MutationStage # record the value in force
nodetool setconcurrency MutationStage 64 # applies to this node only

After confirming a value helps on that node, persist it in cassandra.yaml and roll it out with the other write-path settings:

# Increase write timeout
write_request_timeout_in_ms: 10000 # default: 2000
# Persist a value already validated with nodetool setconcurrency above
concurrent_writes: 64 # default: 32
# Optimize commit log
commitlog_sync: periodic
commitlog_sync_period_in_ms: 10000
  1. Review data model:
  • Check for hot partitions
  • Split large partitions
  • Reduce write amplification
  1. Optimize hardware:
  • Use NVMe for commit log
  • Increase network bandwidth
  • Add RAM for more memtable space

# Appropriate timeouts
write_request_timeout_in_ms: 5000 # 5 seconds
# Thread pool sizing baseline, not a remedy for timeouts
concurrent_writes: 32 # Based on disk count
# Proper sizing
# memtable_heap_space_in_mb: adequate for workload
# Alert on:
- Write latency p99 > 1 second
- Dropped MUTATION messages > 0
- MutationStage pending > 100
- Disk I/O await > 10ms
// Set appropriate timeouts
DriverConfigLoader loader = DriverConfigLoader.programmaticBuilder()
.withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofSeconds(10))
.build();
// Use async writes for high throughput
session.executeAsync(statement);
// Implement proper error handling
try {
session.execute(statement);
} catch (WriteTimeoutException e) {
// Log and handle appropriately
// Consider: retry, queue for later, alert
}