Cassandra extract counts differ between two runs on one day, and cancelled subscriptions reappear — diagnose from the facts
A daily job extracts billing.active_subscriptions from a six-node, one-datacenter Cassandra cluster into the warehouse. Cancelling a subscription DELETEs its row. Finance noticed two things: a rerun on the same morning returns a different count, and about 3,000 subscriptions cancelled in October are back in the extract, although the app shows them as cancelled. Gather what the facts below explain. Constraints: explain both symptoms, then give the repair for the data already in the cluster and the changes that stop it from happening again.
keyspace billing: replication = {'class': 'NetworkTopologyStrategy', 'dc1': 3}
table active_subscriptions: gc_grace_seconds = 864000
app writes and deletes: consistency ONE
extract (Spark connector): spark.cassandra.input.consistency.level = LOCAL_ONE
cassandra.yaml: max_hint_window: 3h
node c3: down 2026-10-03 .. 2026-10-15 (12 days), rejoined without rebuild
last completed repair on billing: 2026-09-28
run 07:10 rows = 1,284,331
run 07:55 rows = 1,286,904Diagnose the cause.
Writes and reads at ONE need not overlap (1 + 1 < 3), so each run reads whichever replica answers. c3, down 12 days past the 3-hour hint window, missed October's deletes; the others purged those tombstones after 10 days, so c3's rows came back. Re-delete, repair, use QUORUM.
- Trusting hinted handoff to deliver every missed write, when hints stop after
max_hint_window(3 hours by default) - Letting a node that was down longer than
gc_grace_secondsrejoin without wiping and rebuilding it - Shortening
gc_grace_secondsto make tombstones disappear, which makes resurrection more likely, not less
- How would the warehouse catch resurrected rows without trusting Cassandra, for example against a CDC feed?
- Which repair schedule keeps a table with deletes safe, and how does it relate to
gc_grace_seconds?
The count drift. RF 3, writes at ONE, reads at LOCAL_ONE: R + W = 2, not more than 3. In each run every token range is read from whichever replica answers first; when replicas disagree (and after c3's 12-day outage and five weeks with no repair, they do), two consecutive runs see different sets of rows.
The resurrection. The timeline:
- 3–15 October, c3 is down. Hints for it are kept only for the first 3 hours (
max_hint_window); later deletes never reach c3. - The other two replicas of each row hold the tombstone; after
gc_grace_seconds(10 days) compaction drops it. - On 15 October c3 rejoins, without a rebuild, holding the old live rows. Nobody holds the markers that would shadow them any more: read repair and any repair now spread the live row back.
A node that was down longer than gc_grace_seconds must not simply be started: it is wiped and brought back by streaming its data from the replicas (for example with replace_address_first_boot), or it brings deleted data back.
The fix.
- Data: take the list of cancelled subscriptions from the system of record (the app database, CDC) and delete the rows again, then run a full repair.
# after the re-deletes: a full repair of the keyspace, node by node
nodetool repair -full billing- Process: repair
billingbeforegc_grace_secondsruns out (with the 10-day default the documentation suggests every node once every 7 days; schedule it through Reaper or similar); the runbook says a node down longer than that is only ever rebuilt. - Consistency: writes and deletes at
QUORUM(LOCAL_QUORUM), the extract atLOCAL_QUORUM. - Warehouse: reconcile deletes against CDC or the system of record instead of treating a Cassandra scan as the whole truth.