Order Systems That Do Not Lose Money: A Reference Design and Fault-Injection Evaluation of Consistency Patterns on a Single Relational Database

Order and payment code in web applications is usually written as a sequence of reads, checks and writes that is correct when one user acts at a time. In production the same code meets concurrent buyers, client retries, payment providers that deliver webhooks more than once and out of order, and processes that crash between two steps. This paper (i) defines a failure model with six failure modes that cost money or customers; (ii) presents a reference design for a complete order life cycle (checkout, stock reservation, payment, fulfilment, partial refunds) that combines an explicit state machine, transactional idempotency keys, conditional stock reservation, a guarded webhook inbox, a transactional outbox, a double-entry ledger with unique references, and reconciliation, all on a single PostgreSQL database; (iii) provides an open-source TypeScript implementation; and (iv) evaluates it against common naive designs in seven fault-injection experiments, each repeated ten times. Under contention the naive designs sold up to 50 units of a product that had one unit in stock, created one order per retried submission, left 54% of orders in a wrong final state and overstated revenue by 151% when webhooks were duplicated and reordered, lost 9.5% of events when the process crashed after commit, and accepted refunds far above the captured amount for 99% of orders. The reference design produced no invariant violations in any run, repaired all drift caused by up to 20% lost webhooks, and did so at the cost of roughly 2.7x the median latency of an unprotected checkout when there is no contention.

Authors

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2026-12-01
DOI
https://doi.org/10.5281/zenodo.24716751
Primary Topic
Distributed systems and fault tolerance
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

Order Systems That Do Not Lose Money: A Reference Design and Fault-Injection Evaluation of Consistency Patterns on a Single Relational Database

Nitesh Das
Zenodo (CERN European Organization for Nuclear Research)
Distributed systems and fault tolerance
preprint

Order Systems That Do Not Lose Money: A Reference Design and Fault-Injection Evaluation of Consistency Patterns on a Single Relational Database

Nitesh Das
preprint en

Abstract

Order and payment code in web applications is usually written as a sequence of reads, checks and writes that is correct when one user acts at a time. In production the same code meets concurrent buyers, client retries, payment providers that deliver webhooks more than once and out of order, and processes that crash between two steps. This paper (i) defines a failure model with six failure modes that cost money or customers; (ii) presents a reference design for a complete order life cycle (checkout, stock reservation, payment, fulfilment, partial refunds) that combines an explicit state machine, transactional idempotency keys, conditional stock reservation, a guarded webhook inbox, a transactional outbox, a double-entry ledger with unique references, and reconciliation, all on a single PostgreSQL database; (iii) provides an open-source TypeScript implementation; and (iv) evaluates it against common naive designs in seven fault-injection experiments, each repeated ten times. Under contention the naive designs sold up to 50 units of a product that had one unit in stock, created one order per retried submission, left 54% of orders in a wrong final state and overstated revenue by 151% when webhooks were duplicated and reordered, lost 9.5% of events when the process crashed after commit, and accepted refunds far above the captured amount for 99% of orders. The reference design produced no invariant violations in any run, repaired all drift caused by up to 20% lost webhooks, and did so at the cost of roughly 2.7x the median latency of an unprotected checkout when there is no contention.

Zenodo (CERN European Organization for Nuclear Research)
Distributed systems and fault tolerance
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon
Order Systems That Do Not Lose Money: A Reference Design and Fault-Injection Evaluation of Consistency Patterns on a Single Relational Database — Nitesh Das · Zenodo (CERN European Organization for Nuclear Research) (2026) | TGRS Research Map | TGRS