Intermediate
Open
Pro
Diagnosing Lost Events and Applying the Outbox Pattern
An inventory service does the following on every stock adjustment:
db.execute("UPDATE stock SET qty = qty - :n WHERE sku = :sku")
db.commit()
producer.send("stock-events", key=sku, value=StockChanged(sku, -n))
About 0.02% of adjustments never reach the search-index consumer, and the number spikes during deploys.
- Explain the failure mode precisely, and why swapping the two statements does not fix it.
- Redesign the write path with the transactional outbox pattern. Include the table shape and the two ways the relay can be built.
- The relay is itself at-least-once. Explain what that implies for the search-index consumer, and how you preserve per-SKU ordering through the relay.
Share this question