Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

What is a tombstone in Cassandra, when is one created, and why does deleting data not free space immediately? What does gc_grace_seconds control?

A tombstone is a marker Cassandra writes instead of erasing data, because data sits in immutable SSTables on several replicas and cannot be removed in place; the tombstone has a timestamp and shadows any older value. Tombstones are created by DELETE, by TTL expiry, by writing null to a column and by overwriting a whole collection. Space is freed only when compaction drops both the data and the tombstone, and only after gc_grace_seconds (10 days by default), which must be longer than the repair interval so a replica that missed the delete cannot bring the data back.

Why this question is asked

Deleting data in Cassandra surprises everyone the first time: the disk does not shrink, reads can get slower, and in the worst case deleted rows come back. All of this follows from one design decision, that Cassandra never modifies a file once written. Interviewers ask about tombstones because they are behind a large share of Cassandra performance problems and data correctness incidents. In this answer, we will recap how Cassandra stores data, see what a delete actually writes, list the less obvious ways tombstones appear, follow how space is eventually reclaimed, understand gc_grace_seconds and zombie data, and look at the cost tombstones add to reads.

1A Quick Recap of Cassandra's Storage

A write in Cassandra goes to the commit log and to the memtable, an in-memory sorted structure. When the memtable fills, it is flushed to disk as an SSTable, a sorted, immutable file. Over time a table has many SSTables, and a single row can have pieces in several of them. A read merges those pieces, keeping the value with the newest timestamp for each cell. Compaction periodically merges SSTables into fewer, larger ones, discarding values that have been overwritten.

Because SSTables are immutable, Cassandra cannot reach into an old file and erase a row. And because each row lives on several replicas, a delete must also reach all of them, including any that are down at that moment.

2What a Delete Actually Writes

So a delete is just another write: it writes a tombstone, a marker that says this data was deleted at this timestamp. During reads, the tombstone shadows any value with an older timestamp, so the data appears gone even though its bytes are still in older SSTables.

SQL
DELETE FROM sessions WHERE user_id = 42 AND session_id = 7; -- writes a row tombstone, ts = 10:15
SELECT * FROM sessions WHERE user_id = 42 AND session_id = 7; -- 0 rows
-- on disk:
-- sstable-1 (written 09:00): user 42, session 7, data ... <- still there
-- sstable-5 (written 10:15): user 42, session 7, TOMBSTONE <- shadows it on read

Notice that after the delete we have used more disk, not less: the original data plus a tombstone. Tombstones come in several sizes: a cell tombstone for one column, a row tombstone, a range tombstone for a slice of clustering keys, and a partition tombstone when we delete a whole partition. Larger ones are more efficient, which is why deleting a partition is far cheaper than deleting its rows one by one.

3The Less Obvious Ways Tombstones Appear

DELETE is the obvious source. Three others catch teams out. TTL expiry: when a cell's time to live passes, it becomes a tombstone, so a table with a TTL generates tombstones continuously. Writing null: an INSERT that sets a column to null writes a tombstone for that column, which is common when a Java object with null fields is saved through a mapper or a prepared statement with nulls bound. Overwriting a collection: setting a list, set or map column to a new value, as in UPDATE ... SET tags = {'a','b'}, first writes a tombstone for the old collection, then the new elements.

Where tombstones come from
OperationTombstone writtenHow to avoid it
DELETE row or partitionRow, range or partition tombstonePrefer partition deletes or TTL + TWCS
TTL expiryCell tombstone per expired cellDrop whole SSTables with TWCS
INSERT with null columnCell tombstoneLeave values unset instead of null
SET collection = {...}Collection tombstone + new cellsAppend with col = col + {...}

The null case is the most frequent surprise in Java services. With the DataStax driver 4.x, leaving a bound value unset, rather than binding null, writes nothing for that column, and Spring Data Cassandra can be configured to skip null properties on insert; check your version's options. For collections, appending with tags = tags + {'c'} adds elements without a tombstone.

4How Space Is Finally Reclaimed

Tombstones and the data they shadow are removed by compaction, but only under two conditions. First, the tombstone must be older than gc_grace_seconds, which is 864,000 seconds, ten days, by default. Second, compaction must be able to see that no older SSTable outside the compaction still holds data the tombstone shadows; otherwise dropping the tombstone would make that data visible again.

So the timeline for a deleted row is: deleted on day 0, tombstone and data both kept until day 10, removed at the first compaction after day 10 that includes all the relevant SSTables. With size-tiered compaction on a large table, that can be weeks later.

Step throughLife of a deleted row
  1. DELETE at day 0Tombstone written to memtable
  2. Flushed to a new SSTableOld data still in older SSTables
  3. Reads merge and skipTombstone shadows the old value
  4. gc_grace_seconds passed?10 days by default
    YesEligible for removalNoKeep both
  5. Compaction includes all copiesData and tombstone dropped, space freed

5 steps in order. Play them, or step through them one at a time.

5What gc_grace_seconds Protects Against

Why wait ten days? Imagine a replica that was down when the delete happened. It still holds the old data and has no tombstone. Repair, which compares replicas and copies missing data, is what eventually delivers the tombstone to it. If the other replicas compacted away their tombstones before repair ran, they would have neither data nor tombstone, while the returning replica has the data. The next repair would see data on one replica and nothing on the others, and copy the data back everywhere. The deleted row is resurrected; this is called zombie data.

So gc_grace_seconds must be longer than the interval in which every replica is guaranteed to be repaired. If repairs run weekly, ten days gives a three-day margin. If a node can be down longer than gc_grace_seconds, it must not simply rejoin; it must be rebuilt.

6The Cost of Tombstones on Reads

Until compaction removes them, tombstones must be read. A query that scans a range in a partition with many deleted rows has to read and skip every tombstone to find live rows, and keeps them in memory while doing so. Cassandra warns when a single query scans more than tombstone_warn_threshold, 1,000 by default, and aborts the query with a TombstoneOverwhelmingException when it reaches tombstone_failure_threshold, 100,000 by default. Check your version for the exact setting names, which changed in Cassandra 4.1 and later.

This is why delete-heavy patterns, such as using a table as a queue, perform badly, and why data models that expire data by dropping whole partitions or whole SSTables, with TTL and TimeWindowCompactionStrategy, behave so much better.

7Follow-up questions

Can we just lower gc_grace_seconds to free space sooner?

Only if repairs reliably complete within the shorter window, otherwise we risk zombie data. For tables that are written once with TTL and never deleted explicitly, and where all writes use the same TTL, lowering it is common, because replicas expire the data on their own. For tables with explicit deletes, the safe approach is to keep it above the repair interval with margin.

How do we find out whether a table has a tombstone problem?

Look for the tombstone warnings in system.log, check nodetool tablestats for average and maximum tombstones per slice, and enable tracing on a suspicious query, which reports how many live rows and tombstones it read. The sstablemetadata tool shows the estimated droppable tombstones per SSTable.

8Conclusion

In this answer, we saw that Cassandra deletes by writing a tombstone, because SSTables are immutable and replicas must all learn of the delete. Tombstones come from DELETE, TTL expiry, null writes and collection overwrites. Space is reclaimed only when compaction drops data and tombstone together after gc_grace_seconds, ten days by default, which must exceed the repair interval to prevent zombie data. Meanwhile reads must skip tombstones, with warnings at 1,000 and failures at 100,000 per query by default.

What to say in the interviewAbout 90 seconds aloud

Open with

A tombstone is how Cassandra deletes. Data lives in immutable SSTables on several replicas, so a delete cannot erase anything in place; instead it writes a marker with a timestamp, and on reads that marker shadows any older value.

Then, if they want more

Tombstones come from DELETE statements, but also from TTL expiry, from writing null to a column, which is easy to do by accident from Java, and from overwriting an entire collection. That is why deleting does not free space: right after a delete we actually have the old data plus the tombstone.

Both are removed only by compaction, and only once the tombstone is older than gc_grace_seconds, ten days by default, and the compaction covers the SSTables holding the old data. gc_grace_seconds exists to prevent zombie data. A replica that was down during the delete still has the data, and repair is what delivers the tombstone to it.

If the others dropped their tombstones before that repair, the stale replica would spread the data back. So gc_grace_seconds must be longer than our repair interval, and a node down longer than that has to be rebuilt.

Tombstones also cost reads, because scans must skip them; Cassandra warns at 1,000 per query and fails at 100,000 by default, which is why queue-like delete patterns are a problem.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is a tombstone in Cassandra, when is one created, and why does deleting data not...": https://scrivio-interview-library.netlify.app/databases/cassandra-and-dynamodb/72b2d05236/