Operations a Staff Engineer Must Understand

Parts 2 through 8 described a system that stays correct as long as its background machinery keeps running. This part is that machinery from the operator's side: repair, manual compaction, streaming data onto a new node, and taking nodes away again. The consequence worth internalizing is that Cassandra's correctness has a deadline — every replica must be repaired within gc_grace_seconds, or deleted data comes back — and most of the ways clusters die in production are an ignored deadline or a data model that made the machinery too expensive to keep up.

nodetool repair

What Consistency Problem Does It Fix?

Repair is the antidote to replica divergence — the state where different replicas have different data for the same partition key.

Divergence happens because:

  • A node was down during a write and missed it (hinted handoff covered this only within the hint window)
  • Hints expired before the node recovered
  • A tombstone was applied to some replicas but not others before gc_grace_seconds elapsed
  • Network partitions caused writes to commit to some replicas but not others
MechanismWhat it fixes
Read repairRows that are actually read.
Hinted handoffRecent missed writes.
nodetool repairThe catch-all that fixes everything else.

How Repair Works

nodetool repair compares data on replicas using Merkle trees (hash trees). Each node builds a Merkle tree over its data for a key range — a tree of hashes where each leaf is a hash of a row and each internal node is a hash of its children. Two nodes exchange Merkle tree root hashes. If the roots differ, they recursively descend the tree to find which subtrees (and eventually which rows) diverge. Only the differing rows are streamed — not the entire dataset.

Two replicas build Merkle trees over the same token range. Each has four leaves, one per token sub-range, and each leaf hashes every partition in that sub-range. The roots differ, 9f3a vs 41c7. The left children match (2b10) so that half is pruned. The right children differ (7e02 vs c518), and below them range 3 differs (c3 vs e9) while range 4 matches. Only sub-range 3 is streamed, but all of it — every partition in the leaf, matching or not.
Two Merkle trees, one mismatch path — and the whole leaf range gets streamed

This is efficient, but still expensive:

  • Building Merkle trees requires reading and hashing all on-disk data in the repaired range
  • On large nodes (multi-TB), this takes hours and produces significant I/O
  • Repair is single-threaded by default per table (parallelism is tunable)

What Happens If You Never Run Repair?

After gc_grace_seconds (default 10 days) elapses, tombstones may be garbage-collected on nodes that received them — but not on nodes that missed them. The deleted data permanently resurrects on the out-of-sync nodes. You now have zombie rows in production that should not exist.

Timeline, not to scale. A DELETE writes a tombstone on node A while node B is down and misses it. The hint window ends after 3 hours by default, so the hint is gone; B keeps the old row live. Any full repair before gc_grace_seconds, 10 days by default, would copy the tombstone to B and prevent the problem. If none runs, compaction on A drops the tombstone and the old row after gc_grace_seconds. The next read repair or repair then copies B’s old row back to A: the deleted row is back, a zombie.
A delete becomes a zombie row when no repair lands inside gc_grace_seconds

Beyond zombie data, long-running divergence means read repairs become more expensive, and quorum reads start surfacing inconsistencies that are visible to users.

Operational rule: run repair on every node at least once within every gc_grace_seconds window.

Many operators use cassandra-reaper (a dedicated repair scheduler) to run incremental repairs continuously in the background, spreading the I/O load across time.

  • Guarantees: After a successful repair of a range, every replica of it holds the union of what any replica held — including every tombstone — so a later tombstone purge cannot resurrect anything.
  • Does not guarantee: Anything about data written after the repair started, or minimal network cost — divergence is found at sub-range granularity, so repair can stream far more than actually differs.

nodetool compaction

When Do You Trigger It Manually?

Normally, compaction runs automatically based on your compaction strategy's thresholds (Part 6). You trigger it manually when:

  1. After a bulk data load — a massive import creates many SSTables quickly. Manually triggering compaction consolidates them before the cluster goes live with traffic.
  2. To evict expired tombstones quickly — if you need deleted data to disappear sooner than the background compaction schedule would allow (e.g., after a bulk delete for compliance).
  3. Before a repair — compacted data means less data to hash and fewer SSTables for the repair to process. Running nodetool compact before nodetool repair reduces repair duration.
  4. Recovering from compaction backlog — if a node accumulated a large backlog of SSTables (e.g., during a write storm), manually triggering compaction clears the backlog faster.
# Compact a specific table
nodetool compact <keyspace> <table>

# Compact everything on the node
nodetool compact
  • Guarantees: Fewer SSTables per partition afterward — cheaper reads and less for a following repair to hash.
  • Does not guarantee: Completion under tight disk, or removal of tombstones still inside their gc_grace_seconds window.

Bootstrapping a New Node

When you add a node to the cluster, it must receive a copy of the data it will be responsible for. This process is called streaming. (The token-ring side of joining is in Part 2 — adding a node.)

How Streaming Works

  1. The new node announces itself via gossip and claims its token ranges
  2. Cassandra identifies which existing nodes own the data for those ranges
  3. Those nodes stream SSTables (or individual rows, depending on version) to the new node
  4. Once streaming completes, the new node starts serving traffic for its ranges

Why It Slows Down the Cluster

Streaming is network and I/O intensive on both sides:

  • Source nodes read SSTables from disk and send them over the network
  • Source nodes continue serving client traffic while streaming — their disk I/O budget is split
  • New node receives and writes SSTables while potentially serving some traffic
  • Network bandwidth consumed by streaming may crowd out replication of live writes

Mitigations

  • Bootstrap one node at a time — don't add multiple nodes simultaneously
  • Set stream_throughput_outbound_megabits_per_sec to rate-limit streaming I/O (renamed stream_throughput_outbound in 4.1+; also adjustable live with nodetool setstreamthroughput)
  • Bootstrap during off-peak hours
  • If you are replacing a dead node rather than growing the cluster, use replace_address_first_boot (§ 4) so the replacement takes over the dead node's tokens — one round of streaming instead of two. (nodetool rebuild is a different tool: it populates a new datacenter by streaming from an existing one.)
  • Guarantees: The new node serves its ranges only after it has received the data for them.
  • Does not guarantee: Unaffected latency on the source nodes while it happens, or that the copy is any more complete than the source replica it streamed from.

Decommissioning, Replacing, and Removing a Node

Decommissioning a Live Node (Graceful Removal)

nodetool decommission

A node that is still alive announces that it is leaving. It streams its data to the nodes that will own its token ranges after it leaves. Only when all streaming is complete and all replicas are confirmed does it remove itself from the ring.

Safe  Data is preserved. No data loss.

Replacing a Dead Node (Keeps the Same Tokens)

# JVM option on the replacement machine, before its first start
# (jvm.options, or JVM_OPTS in cassandra-env.sh)
-Dcassandra.replace_address_first_boot=<dead_node_ip>

Set this on a brand-new, empty node and start it. It joins claiming the exact token ranges of the dead node instead of generating its own, so the ring shape — ownership, replica placement, all of it — is unchanged. It then bootstraps those ranges by streaming from the surviving replicas (the other RF−1 copies), since the dead node obviously cannot stream anything itself.

This is the normal response to hardware failure. One round of streaming, and when it finishes you are back at full replica count with the topology you started with.

Details that bite:

DetailWhy it bites
Fresh node, same rack and DCThe replacement must be genuinely fresh — empty data/, commitlog/, saved_caches/ — and must land in the same rack and DC as far as your snitch is concerned. If it doesn't, replica placement shifts under you and you've silently done something other than a replacement.
_first_boot, not the plain formPrefer replace_address_first_boot to the older replace_address. The first_boot variant is ignored once the node has bootstrapped successfully, so a later restart can't accidentally re-run the replacement; the plain form has to be removed from the config by hand.
One source per rangeBootstrap streams one source replica per range, so the replacement inherits whatever gaps that source had. Run nodetool repair on the new node once it's up.
RF−1 for the whole bootstrapThose ranges sit at RF−1 live replicas for the entire bootstrap — hours on a dense node. With RF=3 that means QUORUM still works but has zero headroom for a second failure.

Removing a Dead Node (Forced Removal, Shrinks the Cluster)

nodetool removenode <host_id>

Use this when you are permanently shrinking the cluster, or when the dead machine isn't coming back and isn't being replaced. The dead node is evicted from the ring and the remaining nodes claim its token ranges — but they hold no data for those ranges, because the dead node couldn't stream anything to them. If RF=3, those ranges now have 2 live replicas instead of 3.

Risky  After removenode you are operating at reduced replica count for those ranges. Run nodetool repair on the affected ranges immediately to restore full replication across the surviving nodes.

Choosing Between Them

decommissionreplace_address_first_bootremovenode
Node stateAliveDeadDead
Cluster size afterward−1Unchanged−1
Ring / token layoutRanges redistributedUnchanged — replacement inherits tokensRanges redistributed
Who streams the dataThe leaving node itselfSurviving replicas → replacementSource notes: "Nobody; repair does it later." Actual: surviving replicas → new range owners during removenode; repair afterwards to close gaps
Rounds of streaming111 (source notes: the repair; actually the removenode streaming), plus another full bootstrap if you later add a node back
  • Guarantees: decommission loses nothing; replace_address_first_boot restores full replica count with an unchanged ring in one round of streaming.
  • Does not guarantee: Full redundancy during the operation — any range that lost a replica stays at RF−1 until streaming finishes — or that streamed copies are complete without a follow-up repair.

Anti-Patterns That Kill Cassandra Clusters in Production

1. Unbounded Partition Growth

A partition key that doesn't bound the number of rows — e.g., user_id with no time bucketing on an event table. As users accumulate activity, some partitions become enormous. Eventually:

  • Reads on large partitions time out or spike in latency
  • Compaction on large partitions takes hours and starves other operations
  • The node hosting the partition becomes a hot spot and falls behind

Fix: always estimate maximum partition size at design time. If unbounded, add a time or hash bucket to the partition key (Part 7).

2. Tombstone Storms

Workloads that delete or expire many rows, combined with:

  • The wrong compaction strategy (STCS instead of TWCS for time-series)
  • Infrequent compaction
  • A data model that deletes individual rows rather than whole partitions

Result: tombstones accumulate until reads hit the 100,000 tombstone threshold and throw TombstoneOverwhelmingException. The table becomes unreadable. (Tombstones on the read path: Part 5.)

Fix: use TWCS for time-series data, TTLs at the table level, and monitor tombstone counts before they become a crisis.

3. Missing Repair Schedule

Running Cassandra without automated repairs is gambling. Every missed repair window increases the risk of zombie data after gc_grace_seconds (§ 1). Most teams don't notice until a compliance audit or a data integrity investigation surfaces phantom rows.

Fix: deploy cassandra-reaper or equivalent. Run incremental repair continuously. Treat a repair lag alert the same way you'd treat a replication lag alert on Postgres.

4. Wrong Compaction Strategy for the Workload

The most common: STCS on a table with many deletes or updates. STCS is optimized for write throughput on append-only data. On update-heavy tables, STCS accumulates many versions of the same row across tiers, making reads expensive and compaction slow.

Fix: audit every table's compaction strategy against its write pattern (Part 6).

Write patternStrategy
Update-heavy tablesLCS
Time-series with TTLTWCS
Append-only workloads where you rarely read by primary keySTCS

5. Using ALLOW FILTERING or Secondary Indexes in Production

Both scan every node in the cluster. Under load, these queries monopolize thread pools and cause cluster-wide latency spikes. A single bad query on one endpoint can slow down unrelated workloads on the same cluster.

Fix: treat any occurrence of ALLOW FILTERING in production code as a P1 incident. Build a new table with the correct partition key for the query instead.

  • Guarantees: Bounded partitions, a strategy matched to the write pattern, partition-key-only queries and continuous repair keep every background mechanism in this guide cheap enough to keep up.
  • Does not guarantee: That you can fix any of these cheaply later. A partition key or a compaction backlog on a live multi-TB table is a migration, not a config change.