The Phantom Transaction
This e-commerce order handler performs inventory locking, order creation, and an external payment API call all within a single database transaction. Under load, the connection pool is exhausted because each connection is held for the full duration of the external HTTP call. Worse, if the payment succeeds but the commit fails, the customer is charged while inventory rolls back. Refactor the code to separate the transaction boundary from the external call and handle all failure modes.
Start Voice Recording
Record your voice to explain your thought process
Challenge the Scenario
Fix the bug and run your code to verify
Stop & Submit for AI Review
Get professional feedback on your approach
Explain Your Approach
Design Rationale — Auto-transcribed from your voice. Feel free to edit or type directly.
Code Editor
Fix the code and explain your rationale (voice/text) to submit.