Database / Apache Cassandra Intermediate and Advanced interview questions
What is gc_grace_seconds and why does it matter?
gc_grace_seconds is a per-table setting that defines how long a tombstone must be kept before it becomes eligible for permanent removal during compaction. It defaults to 864000 seconds (10 days).
- The window exists to give every replica a chance to receive the delete, whether through the original write, hinted handoff, or anti-entropy repair.
- If a tombstone is purged before an out-of-sync replica ever saw it, that replica's old, undeleted copy can resurface during a later read or repair — this is called zombie data.
- The operational rule of thumb is: always run repair more often than gc_grace_seconds, so every replica is guaranteed to be reconciled before tombstones age out.
ALTER TABLE sessions WITH gc_grace_seconds = 86400; -- 1 day, common for tables with heavy deletes/TTL
Lowering gc_grace_seconds is common on tables that rely heavily on TTL expiration (to reclaim disk space faster), but it is only safe if repairs are actually scheduled frequently enough to keep pace with the shorter window.
More Related questions...