System Design Atlas

International humanitarian aid logistics

07 / 10Worked example

Critical flow

Contention ends before shipping. What conditions ensure the result?

Two shipments claim 100 available boxes.

Starting point The synchronisation adapter accepts records; the API manages inventory.

Assumptions for the example case

A fictional shipment of 100 boxes of hygiene supplies between a warehouse and a distribution point. Local inventory ownership remains clear; offline devices document assigned shipments. All quantities, thresholds and operational targets in this design are illustrative assumptions.

Duplicate handover synchronisation

Duplicate handover synchronisation

98 accepted and 2 damaged boxes are booked once.

Transportation device
Sync adapter
Shipment records
Evidence store
  1. 01 Transportation device → Sync adapterU-49 · 98/2
  2. 02 Sync adapter → Evidence storeStore U-49 immutably
  3. 03 Evidence store → Sync adapterImmutable record fully stored
  4. 04 Sync adapter → Shipment recordsCommit evidence reference + quantity effect atomically
  5. 05 Shipment records → Sync adapterCommit is durable
  6. 06 Sync adapter · Local processingResponse lost
  7. 07 Transportation device → Sync adapterU-49 again
  8. 08 Sync adapter → Transportation devicehistorical 98/2

Result: One quantity effect; all 100 remain accounted for.

Committing before responding enables safe replay without a second quantity effect.

The device sends U-49; commit; response lost; replay reads the stored 98/2 result; no second quantity effect.

Commit, response loss and resumption

C-49 available 100
Attempt two allocations of 100 in both arrival orders → One succeeds, the other is rejected; available stock 0.
U-49 stored with 98/2
Identical replay, then 99/1 under the same identifier → One quantity effect; the changed replay conflicts.
S-49 shipped 100
Receipt totals 99/100/101 → 99 leaves 1 unaccounted for; 100 can be fully accounted for; 101 conflicts without changing quantities.

Resolve competing allocations before dispatch.

Resolve competing allocations before dispatch.

Allocation checks and reserves stock atomically.

Two shipments claim 100 available boxes.

A receives 100, B is rejected, available stock 0. B receives 100, A is rejected, available stock 0.

Alternative considered
Cleaning up after dispatch is too late.
Trade-off
Unsuccessful shipments wait for replenishment.
Reassess
Partial allocation needs its own contract.

Try it yourself

Predict both orders and stock.

A hint for your attempt

Two shipments claim 100 available boxes.

Compare with a possible solution
A first
A receives 100, B is rejected, available stock 0.
B first
B receives 100, A is rejected, available stock 0.

Apply to your project

How does “Resolve competing allocations before dispatch” apply to your own project?

Step 8: Missing files and missing goods require different actions. Which conditions ensure this outcome?