← All Insights

PRIMESHIFT INSIGHTS · June 10, 2026

Idempotency Keys at Edge Gateways: Preventing Duplicate ISO 20022 Wire Settlements

Designing atomic lock-and-commit Postgres idempotency tables so mobile network retries never trigger double clearing postings.

Geometric event-sourced double-entry financial ledger routing schematic
WED, JUN 10, 2026·7 min read·Architecture & Distributed Systems·Issue #27 · Core Dispatches
Dispatch Issue #27 · Key Metric: 0 duplicate ledger postings across 18M mobile/B2B retry events

Production Context & Why This Matters

Network blips on mobile banking and corporate ERP connections guarantee clients will retry timed-out POST settlement requests. Without transactional idempotency keys anchored in durable storage, retries create catastrophic duplicate wires.

Effective idempotency enforces a composite unique constraint over `(merchant_id, idempotency_key)` coupled with payload SHA-256 verification so mismatched retries return crisp 409 Conflict responses.

Architectural Mechanics & Reference Implementation

Recording intermediate `IN_FLIGHT` locks guarantees concurrent identical requests block cleanly and receive the exact cached HTTP 200 response payload.

INSERT INTO idempotency_keys (merchant_id, key_hash, payload_sha, state)
VALUES ($1, $2, $3, 'IN_FLIGHT')
ON CONFLICT (merchant_id, key_hash) DO NOTHING;

Verified Operational Benchmarks

Deploying atomic gateway guards eliminated manual reconciliation refunds caused by flaky client retry storms.

  • Primary Delta: 0 duplicate ledger postings across 18M mobile/B2B retry events
  • Reliability Gate: Atomic SERIALIZABLE lock protection with 7-day deterministic replay cache
  • Ownership Boundary: 100% client-owned IaC & telemetry pipelines audited by Avtar Singh

Implementation Checklist

  • Hash full canonical request bodies to detect accidental key reuse across distinct transfers.
  • Reclaim stale IN_FLIGHT locks cleanly after bounded worker heartbeats expire.
  • Return stored JSON status codes verbatim on safe client replays.
About the Author

Avtar Singh

Senior Systems Engineer & Head of Engineering Operations

Senior Systems Engineer overseeing day-to-day infrastructure operations, SRE incident response, Kubernetes unit-margin telemetry, and zero-downtime production cutovers across PrimeShift Digital enterprise pods.

Read All Stories by Avtar Singh →

In This Dispatch

Evaluating this architecture inside your production stack?

Our Principal Engineering Desk runs two-week topology audits directly inside your organization cloud & GitHub repos.