Dual write debugging lab. The order is saved and the customer got a 201. Shipping never hears about it, or hears about it too early.
Practice debugging a dual write in a live, broken production system in your browser, with RabbitMQ and PostgreSQL. Find the root cause in the logs, terminal and code, fix it, and a load test checks that the fix holds under real traffic.
1. The Incident Context
The warehouse found 37 paid orders from yesterday that were never shipped. The orders service saved each one and returned 201. The shipping service has no record of them. Shipping's logs are also full of order not found errors for orders that *do* exist when you look them up a moment later.
2. Observed Symptoms & Metrics
- Affected Endpoints / Components:
POST /orders on the orders service, RabbitMQ exchange orders (routing key order.created), the shipping consumer that reads queue shipping.order-created, Postgres orders and shipments tables. The orders service and the shipping consumer run in the same app.
- Behavior: When shipping gets an
order.created event, it looks the order up in Postgres and books a shipment. Many of those lookups say order not found, but the same order is there a second later. During short broker drops, some orders are saved and no event ever arrives. Shipping also sometimes gets events for order IDs that never show up in orders at all.
- Error Rate:
POST /orders returns 201 for nearly every request. shipments ends up short.
- System Metrics: The broker is healthy apart from scripted 2-second connection drops. Postgres is healthy.
3. Application Logs
2026/10/12 10:00:00 orders service listening on :8080
2026/10/12 10:00:14 publish order.created 7712: connection closed (order committed anyway)
2026/10/12 10:00:15 shipping: order 7731 not found, dropping event
2026/10/12 10:00:15 shipping: order 7738 not found, dropping event
# psql
SELECT count(*) FROM orders o LEFT JOIN shipments s ON s.order_id = o.id WHERE s.order_id IS NULL;
count
-------
37
4. Your Objective
Step into the live environment while synthetic traffic is running, find the root cause, and patch the code.
To clear this stack, your fix must pass these checks under a 60-second load test at 50 orders/s, with three 2-second broker outages and 1% of orders coming from customers that payment review rejects when the transaction commits:
- Error Rate: Fewer than 1% of
POST /orders requests fail, not counting the rejected ones (order_failed < 1%). Orders from rejected customers must not get a 201.
- Completeness: Within 15 seconds of the test ending, every saved order has exactly one shipment (
orphan_orders == 0).
- Data Integrity: No shipment exists for an order that was rolled back (
phantom_shipments == 0).
Environment note: the shipping consumer is part of the lab code, so you may change both parts of the app. Every .sql file in migrations/ runs in name order each time the app starts. The grader kills the app once mid-test, and clients retry while it restarts.
Toolbox: curl -X POST localhost:8080/orders -H 'Content-Type: application/json' -d '{"customerId": 4, "total": 59.9}', curl localhost:8080/orders/1, psql "$DATABASE_URL", curl -su guest:guest localhost:15672/api/queues, curl -X POST 'localhost:9101/chaos/drop?seconds=2' (drops the app's broker connections). Save a file in the editor to rebuild and restart the app. Click Verify when you think it's fixed.
Terms in this lab: broker (the RabbitMQ server), consumer (the code that reads messages from a queue), exchange / routing key (how RabbitMQ decides which queue gets a message), commit / rollback (making a transaction's changes permanent, or throwing them away).
You can browse stacks without an account. To run labs you sign in with your email or Google account. BustedStack uses your email address to
sign you in, and your name and profile picture to show your account and pre-fill certificates. We never access your Gmail, contacts or Drive,
sell your data or run ad trackers.
This site needs JavaScript to run labs.