Duplicate processing: Customers are being charged twice
Duplicate processing debugging lab. Every checkout carries an idempotency key, yet finance keeps finding customers charged twice for one order.
Practice debugging a duplicate processing 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
Finance escalated a batch of chargebacks this afternoon: customers were billed twice for one order. Every checkout request carries an Idempotency-Key header, and the mobile app retries with the same key when a checkout looks slow. The duplicates are still showing up.
2. Observed Symptoms & Metrics
- Affected Endpoints / Components:
POST /checkout, the payments RabbitMQ queue, the payment worker inside the checkout service, the Postgres payments table.
- Behavior:
POST /checkout returns 202 Accepted and a worker records the charge a moment later. When a client sends the same key more than once, the payments table ends up with more than one charge for that key. The duplicate rate rises with traffic.
- Error Rate: HTTP looks clean, with nearly every request returning 202. The failure only shows up in the money.
- System Metrics: The queue drains normally with no redeliveries backing up, and Postgres is healthy. Charge volume in
payments is well above the number of unique checkouts.
3. Application Logs
2026/10/12 14:20:01 checkout service listening on :8080
# psql: SELECT idempotency_key, count(*), sum(amount) FROM payments GROUP BY 1 HAVING count(*) > 1 LIMIT 3;
idempotency_key | count | sum
------------------------------+-------+--------
order-4-1842-1760278805123 | 2 | 50.00
order-7-1843-1760278805391 | 2 | 168.00
order-2-1844-1760278805602 | 2 | 94.00
(3 rows)
4. Your Objective
Step into the live environment while synthetic traffic is running, diagnose the root cause, and patch the codebase.
To clear this stack, your fix must satisfy these automated verification checks under a 60-second load test:
- Error Rate: Fewer than 1% of requests fail (
http_errors < 1%).
- Data Integrity: No idempotency key is charged more than once, and every checkout is still processed (
data_integrity).
Toolbox: psql "$DATABASE_URL", and curl -X POST localhost:8080/checkout -H 'Content-Type: application/json' -H 'Idempotency-Key: test-1' -d '{"orderId": 1, "amount": 25}'. Save a file in the editor to rebuild and restart the app. Click Verify when you think it's fixed.
Your account and data
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.
Privacy Policy · Terms of Service · Browse stacks ·
hello@bustedstack.com
This site needs JavaScript to run labs.