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:

Terminal window
# Check MutationStage pending/blocked
nodetool tpstats | grep -E "Pool|Mutation"
# Check for dropped messages
nodetool tpstats | grep -E "MUTATION|Dropped"
# High MutationStage pending indicates overload

Resolution:

  • Scale cluster (add nodes)
  • Reduce write throughput
  • Increase concurrent_writes in cassandra.yaml
  • Check for hot partitions

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
# Look for long pauses (> 500ms)
grep -E "pause.*[0-9]{4,}ms" /var/log/cassandra/gc.log

Resolution:

  • Tune GC settings
  • Reduce heap size if too large
  • Consider ZGC (JDK 17+)

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 cassandra.yaml:
# Increase write timeout
write_request_timeout_in_ms: 10000 # default: 2000
# Increase concurrent writes (if CPU available)
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
# Adequate thread pool
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
}