Paths Subjects Questions Quizzes Pricing Search
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.

  1. Explain the failure mode precisely, and why swapping the two statements does not fix it.
  2. Redesign the write path with the transactional outbox pattern. Include the table shape and the two ways the relay can be built.
  3. 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

← Back to Message Queues & Event Streaming practice

We use cookies for product analytics to improve OmniAtlas. See our Privacy Policy.