DEMOHardGo

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.

1

Start Voice Recording

Record your voice to explain your thought process

2

Challenge the Scenario

Fix the bug and run your code to verify

3

Stop & Submit for AI Review

Get professional feedback on your approach

Explain Your Approach

Voice Recorder

Design RationaleAuto-transcribed from your voice. Feel free to edit or type directly.

Code Editor

Loading...
Powered by Go Playground
Output
Click "Run Code" to execute your program...

Fix the code and explain your rationale (voice/text) to submit.