Q: Why are Cassandra queries failing with ReadFailureException or TombstoneOverwhelmingException, and how do you fix it without losing data?
Cassandra interview questions on tombstones: read failures, tombstone thresholds, gc_grace_seconds, TWCS and the schema redesign that stops queue-style deletes.
Want to master this scenario in a live sandbox? KodeKloud's PostgreSQL Database Administration & High Availability Course covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: Cassandra interview questions about tombstones test whether you understand how deletes really work in an LSM-tree database. A delete in Cassandra does not remove data. It writes a marker, called a tombstone, and the real data disappears only when compaction merges the marker with the data after gc_grace_seconds has passed. When a read has to scan thousands of those markers to find a few live rows, the coordinator logs a warning and then aborts the read. The client sees a ReadFailureException, or a plain timeout if the failing replica never answers in time. I walk through this the way I would on a real incident: confirm the symptom in the logs, measure it per table, find the access pattern that creates the tombstones, and then decide between a short-term mitigation and a schema fix. The key point I make to interviewers is that raising thresholds only hides the problem, and lowering gc_grace_seconds without a repair schedule can bring deleted data back from the dead.
Confirm the symptom in system.log and the thresholds that triggered it
Two settings in cassandra.yaml control the behaviour: tombstone_warn_threshold (default 1000) logs a warning when a single read scans that many tombstones, and tombstone_failure_threshold (default 100000) aborts the read with TombstoneOverwhelmingException. The warning line names the keyspace, table and partition key, which is the fastest way to find the offender. The exception is raised on the replica, so the coordinator reports a ReadFailure to the client.
# On each replica, search for the warning and the abort
grep -E 'tombstone cells|TombstoneOverwhelmingException' /var/log/cassandra/system.log | tail -5
# Example line:
# WARN Read 12 live rows and 8421 tombstone cells for query SELECT * FROM shop.job_queue WHERE queue_id = 7 LIMIT 100
# Thresholds currently in force (cassandra.yaml)
grep -E '^tombstone_(warn|failure)_threshold' /etc/cassandra/cassandra.yaml
Measure tombstone pressure per table with nodetool tablestats
I do not guess which table is hurting. nodetool tablestats reports the average and maximum number of tombstones scanned per read slice over the last five minutes, next to live cell counts. A table with a maximum in the thousands and a small live count is the one to investigate. I also trace one slow query in cqlsh to see how many tombstone cells it touches.
nodetool tablestats shop.job_queue | grep -Ei 'tombstones per slice|live cell|SSTable count'
# Average tombstones per slice (last five minutes): 3120.5
# Maximum tombstones per slice (last five minutes): 8421
# In cqlsh, trace a single read
cqlsh> TRACING ON;
cqlsh> SELECT * FROM shop.job_queue WHERE queue_id = 7 LIMIT 100;
# Look for: Read 12 live rows and 8421 tombstone cells
Identify the delete pattern: queue-like tables and null writes
The usual causes are queue-like tables where rows are inserted and deleted from the same partition, wide partitions that mix old deleted rows with new live ones, and application code that writes explicit nulls into columns, because each null creates a cell tombstone. A query that always reads from the start of a clustering order will keep walking over recently deleted rows. Raising tombstone_failure_threshold only moves the cliff and costs heap on the replica, so I treat it as a temporary bridge during the fix.
-- Anti-pattern: a work queue that deletes processed rows
CREATE TABLE shop.job_queue (
queue_id int,
created timeuuid,
payload text,
PRIMARY KEY (queue_id, created)
);
DELETE FROM shop.job_queue WHERE queue_id = 7 AND created = ?;
-- Check for explicit null writes in the app: bind unset instead of null
-- (native protocol v4+ supports unset values in prepared statements)
Redesign with TTL, time bucketing and TimeWindowCompactionStrategy
The real fix is a schema that never reads across dead data. I bucket the partition key by time so old partitions are simply never queried again, set a default TTL so data expires on its own, and use TimeWindowCompactionStrategy so whole expired SSTables are dropped without row-level merging. TWCS works best for append-only time-series data with a consistent TTL and no updates or explicit deletes.
CREATE TABLE shop.job_events (
queue_id int,
bucket date,
created timeuuid,
payload text,
PRIMARY KEY ((queue_id, bucket), created)
) WITH CLUSTERING ORDER BY (created DESC)
AND default_time_to_live = 604800
AND compaction = {'class': 'TimeWindowCompactionStrategy',
'compaction_window_unit': 'DAYS',
'compaction_window_size': 1};
Tune gc_grace_seconds only with a repair schedule behind it
gc_grace_seconds defaults to 864000 seconds (10 days). It is the window in which every replica must receive the tombstone, normally through repair, before compaction is allowed to purge it. If I lower it and a replica that missed the delete comes back later, that replica still holds the old data and no tombstone remains to shadow it, so the deleted row reappears. I only shorten it for tables where I run repair well inside the new window, or for TTL-only tables where it is safe by design.
-- Inspect and change per table
DESCRIBE TABLE shop.job_events;
ALTER TABLE shop.job_events WITH gc_grace_seconds = 259200; -- 3 days, only if repair completes within 3 days
# Then confirm repair cadence
nodetool repair -pr shop job_events
- A Cassandra delete writes a tombstone marker; the data is purged only by compaction after gc_grace_seconds.
- Reads that scan more than tombstone_warn_threshold tombstones log a warning, and more than tombstone_failure_threshold abort with TombstoneOverwhelmingException.
- I find the table with nodetool tablestats, trace the query, and fix the access pattern with time-bucketed partitions, TTL and TWCS.
- Lowering gc_grace_seconds is safe only when repair completes within that window, otherwise deleted data can resurrect.
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
- Raising tombstone_failure_threshold to a huge value to stop the errors Replicas then hold and sort enormous tombstone sets in heap, which trades read failures for long GC pauses and node instability.
- Lowering gc_grace_seconds to purge tombstones faster without checking repair A replica that was down or missed the delete keeps the old row, and with the tombstone gone the row returns to query results.
- Using Cassandra as a queue with insert then delete in the same partition Every consumer read walks over the dead rows from earlier deletes, so latency grows with churn, not with live data.
- Writing explicit null values from the application Each null creates a cell tombstone; use unset values or omit the column instead.