Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungWhy Your AI Chatbot Forgets Everything — And How to Fix It(23.09.2026 um 16:30 Uhr)
Sichere ProgrammierungHow Jev Works: The Logit Trick Behind TypeSafe's System One Model(23.09.2026 um 16:32 Uhr)
Sichere ProgrammierungInterfaces in Java, Explained(23.09.2026 um 16:36 Uhr)
Sichere ProgrammierungWhat Is AI Observability? A Definition for Engineers(23.09.2026 um 16:42 Uhr)
Sichere ProgrammierungSynth-OOP: An Object-Oriented Language Where Operators Become Methods(23.09.2026 um 16:44 Uhr)
Sichere ProgrammierungAI Can Remember Everything. That's Exactly the Problem.(23.09.2026 um 16:44 Uhr)
Sichere ProgrammierungGas Optimization Audit: Curve DEX(23.09.2026 um 16:45 Uhr)
Sichere ProgrammierungDoes finally Run Before return? What javac Actually Does(23.09.2026 um 16:49 Uhr)
Sichere ProgrammierungWhy Your AI Chatbot Forgets Everything — And How to Fix It(23.09.2026 um 16:30 Uhr)
Sichere ProgrammierungHow Jev Works: The Logit Trick Behind TypeSafe's System One Model(23.09.2026 um 16:32 Uhr)
Sichere ProgrammierungInterfaces in Java, Explained(23.09.2026 um 16:36 Uhr)
Sichere ProgrammierungWhat Is AI Observability? A Definition for Engineers(23.09.2026 um 16:42 Uhr)
Sichere ProgrammierungSynth-OOP: An Object-Oriented Language Where Operators Become Methods(23.09.2026 um 16:44 Uhr)
Sichere ProgrammierungAI Can Remember Everything. That's Exactly the Problem.(23.09.2026 um 16:44 Uhr)
Sichere ProgrammierungGas Optimization Audit: Curve DEX(23.09.2026 um 16:45 Uhr)
Sichere ProgrammierungDoes finally Run Before return? What javac Actually Does(23.09.2026 um 16:49 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

The Difference Between Retry and Idempotency They're Not the Same

Let me start with the confusion that prompted this post: in a recent mentoring session, a senior engineer described their payment service as "idempotent" because it had exponential backoff on retries. That's a category error and it's the…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Let me start with the confusion that prompted this post: in a recent mentoring session, a senior engineer described their payment service as "idempotent" because it had exponential backoff on retries. That's a category error and it's the kind of mistake that bites teams in production with real financial consequences.



Retry and idempotency are complementary, not synonymous.






Two Different Actors, Two Different Concerns



Retry logic lives in the client. It's the client's decision to resend a request after a failure or timeout.



Idempotency lives in the server. It's the server's guarantee that receiving the same request multiple times will have the same effect as receiving it once.



These are independent properties. Here's what each combination looks like:



Retries without server idempotency: every retry is a new operation. Network timeout on a payment? Retry charges the customer again. This is the double-charge bug.



Server idempotency without client retries: the server is prepared for duplicates, but the client gives up after one timeout. The payment succeeded, the UI says error. Support tickets follow.



Neither: timeouts result in unknown state, retries cause duplicates, correctness depends on luck.



Both, correctly implemented: the client retries safely, the server deduplicates, the user sees a correct result. This is the design you want.






What Good Retry Logic Looks Like






int attempt = 0;
while (attempt < MAX_ATTEMPTS) {
try {
return paymentClient.submit(request, idempotencyKey);
} catch (TimeoutException | ServiceUnavailableException e) {
long delay = BASE_DELAY_MS * (1L << attempt) + random.nextInt(JITTER_MS);
Thread.sleep(delay);
attempt++;
}
}
throw new PaymentSubmissionFailedException("Max retries exceeded");






The critical detail: the same idempotency key on every retry attempt. If you're generating a new idempotency key on each retry, you've broken the connection between retry and idempotency. Each retry looks like a new request to the server.






What Good Server-Side Idempotency Looks Like






public PaymentResponse processPayment(String idempotencyKey, PaymentRequest request) {
try (Lock lock = distributedLock.acquire(idempotencyKey)) {
Optional<PaymentResponse> stored = idempotencyStore.get(idempotencyKey);
if (stored.isPresent()) {
return stored.get();
}
PaymentResponse response = paymentGateway.charge(request);
idempotencyStore.save(idempotencyKey, response, TTL_24H);
return response;
}
}






Two non-obvious requirements here:



Distributed lock: without a lock, two concurrent requests with the same key can both pass the "not found" check and both execute the payment.



Durable storage: the idempotency store must survive restarts. A cache with eviction can lose a key making a stored payment look new on the next request.






The Race Condition Most Teams Miss



Without a distributed lock:




  1. Request A arrives. Store check: not found.

  2. Request B arrives (duplicate, concurrent). Store check: not found.

  3. Request A processes payment. Stores result.

  4. Request B processes payment again. Overwrites result.



Customer charged twice. The lock closes this window.






The Atomic Write Problem



What if the server processes the payment but crashes before storing the idempotency key? The client retries. The server has no record of the first request. It processes again.



The cleanest solution is the transactional outbox pattern: write the payment result and the idempotency record in the same database transaction, then publish events asynchronously. It's more complex but eliminates this failure mode entirely.






The Takeaway



Retry is client resilience. Idempotency is server correctness. You need both, explicitly connected via the idempotency key passed on every retry.



When reviewing payment API designs, I check three things: Is the client sending the same key on retries? Is the server storing results durably with a lock? Is the store-and-execute step atomic? If any are missing, the system has a correctness gap that will manifest as duplicate charges under load.






If you found this useful, I run 1:1 mentoring sessions for Java/backend engineers at topmate.io/aliasgar_kantawala



My Java interview guides and system design resources are at aliasgarmk.gumroad.com

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten The Difference Between Retry and Idempotency They're Not the Same

Thematisch verwandte Begriffe: Difference, Between, Retry, Idempotency · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-5695 | Arbitrary file upload vulnerability due to a lack of proper validation in…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick