Code RoomDatabase connection pool leak
HardPrep Room Coding #4409

Database connection pool leak

Vibe & agenticAlgorithms & data structuresMid–Senior~18 min

An AI wrote this FastAPI DB dependency. It works under light load, but after a few hours of traffic the service errors with 'QueuePool limit of size 5 overflow 10 reached, connection timed out'. Find the leak.

Implement
first_pool_exhaustion_index(pool_size: int, max_overflow: int, teardown: str, outcomes: list[str]) → int
Examples
in[5,10,"none",["ok","ok","ok","ok","ok","ok","ok","ok","ok","ok","ok","ok","ok","ok","ok","ok"]]out16
in[5,10,"finally",["ok","error","ok","error","ok","ok","error"]]out0
in[1,0,"after",["error","ok"]]out2
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 18 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.