Stopping delayed retries from resurrecting deleted records

How durable operation receipts and permanent tombstones stop a redelivered create from bringing back a record that was deleted while the create was still in flight.

November 20263 min readMemoryStorageAgent systemsReliability

A low chalk form painted out in a slightly different charcoal remains faintly visible beside one hard-pressed rose mark and sparse green brushing.

Every queue consumer is written for redelivery, and the usual guards, a create-only write or a window of recently seen request IDs, handle duplicate creates and edits well enough that most implementations stop there. Deletion is where they fail without a sound, because both rely on evidence the delete has just removed: a create that was applied, deleted and then redelivered finds an empty key and succeeds. Cassandra operators know the same failure as tombstones purged before a lagging replica is repaired. So forgetting has to be a write: each mutation’s identity travels in the same write as its effect and outlives the operation, and every delete leaves a permanent tombstone for later writes to collide with.

The memory engine of Ferrite, my application platform, keeps what an agent should remember about a user as scoped records in a store, with the vector index, keyword recall and ranking derived from them, and callers reach it over request and reply queues. It is proven locally, by regression tests, not in production.

Operation records and durable receipts

Redelivery can only be recognized when an operation’s identity does not depend on the delivery carrying it. On first arrival, each mutation claims an operation record under the caller’s correlation ID. That record holds a request digest, the ID of any memory the mutation will create, fixed upfront so every delivery targets the same key, and eventually its answer. Redelivering a completed operation returns that stored answer without touching the memory store, while reusing a correlation ID for a different request is rejected.

The crash window sits between writing the memory record and storing the answer in the operation record. If a worker dies in that gap, the operation record still looks unfinished on redelivery, so the memory record itself settles whether the write already landed. A create embeds its operation tag in the record it writes, and an edit appends its tag under compare-and-set in the same write as the change. In a test that corrects a memory to “reads in Spanish”, leaves that operation unfinished, applies a second correction to “reads in Italian”, and redelivers the Spanish edit, the worker finds the first tag already present and leaves the record Italian.

Recognition cannot rely on a bounded window of recent tags inside the record, because queue delays are unbounded. Older tags move to dedicated receipt keys that never expire, and a tag leaves the memory record only after its receipt is written. Because a redelivery checks both locations, an applied mutation stays recognizable regardless of how many edits follow or how late a retry arrives.

Permanent tombstones

Forgetting a memory replaces its record under compare-and-set with a tombstone that keeps only the record ID and drops everything it contained. Reads, listings, and edits treat a tombstone as absent, and nothing removes it.

With the key permanently occupied, any later create-only write fails there regardless of how deliveries interleave with the delete. Because a memory ID belongs to a single operation, a tombstone at that key can only follow that operation’s own create; a redelivery that hits one treats the write as done and returns the original ID.

One test runs the full failure sequence against a real queue and store: remember that a user keeps bees, simulate a crash after the write, forget the record, start a fresh worker, and redeliver the create. The caller receives the original ID, reads and listings find nothing, and recall for “bees” is empty. A second test races two deliveries of a create against a delete for 40 rounds.

Storage growth and replica caches

Every forgotten record leaves a tombstone key behind for good, and every retired operation tag leaves a receipt. Nothing prunes either set, since setting a retention window just picks a date after which forgotten memories are allowed to return. The guarantee is also scoped to storing, listing, and recall rather than every byte on disk: a queued message still carries the original text until it is acknowledged, and the operation record keeps its request digest.

Recall indexes are derived from the store and cached per scope in each replica, which leaves one staleness bound on the read path. A delete processed by one replica does not immediately evict the record from another replica’s cache; until that cache expires, ten seconds by default, the second replica can still return the forgotten record in recall even though the store already holds its tombstone.

Chris Chabot, November 2026