Urgent.News

What's breaking now, across thousands of outlets.

Tech

Bulletproof Idempotency in Distributed Payment Systems: Beyond the Client Header

Most engineers assume handling duplicate payments is as simple as forwarding an Idempotency-Key header downstream to Stripe, Adyen, or Square. Then traffic spikes during a flash sale or network timeout event. Two identical webhook events hit your cluster concurrently, internal retries fire across multiple worker nodes, and your database ends up with duplicate settlement records anyway. External…

The article highlights the common misconception among engineers that idempotency in distributed payment systems can be managed by merely forwarding an Idempotency-Key header from the client to payment service providers (PSPs like Stripe, Adyen, or Square). However, this approach fails during traffic spikes or network timeout events, leading to duplicate settlement records in the database.

External PSPs only ensure idempotency at their boundary, and any internal architecture gaps create vulnerabilities such as out-of-order retries and race conditions that can compromise the ledger.

The article outlines a three-tier architecture to achieve strict end-to-end idempotency in high-concurrency environments:

Layer 1 focuses on deterministic request fingerprinting. Instead of using client-generated UUIDs which can be regenerated during errors, a SHA-256 hash is created from immutable transactional invariants including userId, orderId, currency, and amount. This fingerprint remains consistent even if the client retries the request.

Layer 2 introduces a distributed atomic mutex using Redis SETNX command. Before initiating any external calls or database transactions, the worker must acquire a lock. If another thread attempts the same operation concurrently, the secondary thread either parks and waits for the cached response or retries after an exponential backoff. The lock key is set for 30 seconds to avoid deadlocks.

Layer 3 ensures atomic state machine transitions in the database. Using conditional SQL queries, the database enforces transitions between INITIATED, PROCESSING, and SETTLED/FAILED states. Only one thread can successfully update the status of a payment from PROCESSING. If another thread attempts the same operation, it receives a null result and performs a no-op. This atomic update prevents duplicate transactions and ensures ACID compliance.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

How to Fix Windows Update Error 0x800f081f on Windows 10 and Windows 11

Windows Update error wi* 0x800f081f * is a common problem that can prevent Windows from installing updates or optional features.

  • Built-in troubleshooter in Windows 11 and 10 can resolve Error 0x800f081f
  • Corrupted system files may be the cause; use DISM and sfc /scannow commands
  • Repair Windows component store with DISM commands to fix update issues

GEONMI-MEMS Zero-Heap VLEO Flight Engine

Writing the future of VLEO operations isn't about carrying more weight into space—it's about writing smarter, safer code.

  • GEONMI-MEMS engine eliminates dynamic memory allocation, using static memory and stack allocation.
  • Aero-Ionic Harvesting technology reduces traditional wet mass by up to 40%.

Track which companies are hiring from Greenhouse, Lever and Ashby with a 47-line script

Disclosure: written by an AI agent (Claude) working for Northpine Studio. I ran this script against the live APIs before publishing; the output below is real.

  • Three free public JSON APIs expose job boards for Greenhouse, Lever, and Ashby.
  • Script uses three functions to retrieve job data from each API.
  • Script tracks job lists, identifies added or removed jobs since last check.

More from Tuesday 6 October →