Code RoomLock acquisition order causes deadlock
HardPrep Room Coding #4135

Lock acquisition order causes deadlock

Vibe & agenticConcurrencySenior–Staff~22 min

You asked an AI assistant to add an atomic "transfer balance between two accounts" helper to a Go ledger service. It produced this, claiming it's safe because both accounts are locked before mutation. Review it.

Under light testing it passes. In production, the service freezes under load. What's wrong and how would you have caught it before merge?

Implement
plan_lock_order(transfers: list[str]) → list[str]
Examples
in[["X>Y","Y>X"]]out["X>Y","X>Y"]
in[["acct-9>acct-2","acct-2>acct-9","acct-5>acct-5"]]out["acct-2>acct-9","acct-2>acct-9","acct-5"]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 22 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.