DEV Community

Discussion on: Process-Local Deduplication Breaks the Moment You Add a Second Replica

Collapse
 
mickyarun profile image
arun rajkumar •

The invariant and the test list are right. The line I would not let a reader skim past is the failure one.

A retryable refusal when the replay authority is unavailable is correct, and it is the first thing that gets taken out. Not by anyone careless. It gets taken out because a shared nonce store that is down becomes a total outage on signed ingress, and whoever is holding that pager will eventually be told to accept the request and log it. After that, the replay window is however long the store's worst outage was.

The design question that survives that pressure is narrower than which store to use. It is whether the uniqueness record and the effect can be one write. If the nonce row lives in the same store and the same transaction as the state change the request causes, there is no fail-open decision available to anybody. The store being down means nothing was accepted, and the refusal is not a policy that can be loosened under pressure. Split them and you have two systems with independent availability and a standing temptation.

That constrains the architecture more than the post lets on. Dedup in Redis in front of an effect in Postgres cannot give you this, however correct the SETNX is, because the two can disagree in both directions. Payments works around it by making the idempotency key a unique column on the row that records the effect, which puts the dedup store and the money store in the same database on purpose.

Where it does not generalise is signed ingress whose effect is not a write you own. If the effect is a call to somebody else's API, there is nothing to be atomic with, and you are back to your list with the failure branch as the load-bearing line.

Collapse
 
zenmesh profile image
Zen Mesh Inc. •

Thank you—this is a valuable distinction, and it pushed us to look more closely at our own implementation.

We do have a path that commits a sender idempotency claim and the accepted event together in one SQLite transaction. But that is a specific acceptance boundary; it doesn’t automatically make a separate replay check atomic with acceptance, or make a later external API call part of the same transaction.

Our initial source review also identified replay-path cases we need to investigate, including what happens when a nonce is recorded but the request is subsequently refused, and how concurrent requests and replica membership changes are handled. We’re treating those as open work rather than claiming the broader guarantee is already proven.

We’ll update our public evidence and non-claims as we improve the implementation and validate the relevant scenarios. That distinction between implemented, tested and still-open behavior is the approach we try to describe in Why We Publish What Our Product Doesn’t Do.

Thanks again for making the transaction boundary and the external-effect limitation clearer.