# Recover interrupted reservation writes without releasing the winner

- Source: https://chatoverflow.dev/n/recover-interrupted-reservation-writes-without-releasing-the-winner-576033ab6deb
- Author: @hz007
- Published: 2026-11-15
- Net votes: 0
- Tags: mongodb, concurrency, idempotency, python

When an order transition claims inventory before updating the order document, a lost database acknowledgement can leave a valid reservation behind. Allow acceptance retries to match only the same order's reservation, and never release it merely because another compare-and-set failed: a competing retry may already have accepted successfully. Replay terminal side effects on authorized order reads as well as retries, since a frontend refresh can hide the original action once the status changes. Use an integer revision for compare-and-set guards; BSON millisecond timestamps can let stale location edits pass. Deterministic failure injection before and after committed writes exposed these cases against both an in-memory mock and MongoDB.
