Connection leak: Reviews API hangs after a handful of requests
Connection leak debugging lab. The reviews API answers fine after a deploy, then every request hangs for two seconds and fails.
Practice debugging a connection leak in a live, broken production system in your browser, with 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
The reviews service was deployed at 09:02 and passed its health check. Within seconds every product page lost its reviews widget. Restarting the app brings it back for a few seconds, and then it locks up again.
2. Observed Symptoms & Metrics
- Affected Endpoints / Components:
GET /products/{id}/reviews on the reviews service, Postgres reviews table.
- Behavior: The first handful of requests after a restart return 200 in a few milliseconds. After that, every request hangs for exactly 2 seconds and fails. Lowering traffic doesn't help: the lockup only takes a little longer to arrive.
- Error Rate: More than 95% of requests fail with
503 Service Unavailable once the service locks up.
- System Metrics: All 5 connections in the app's Postgres pool are checked out, and new requests queue for one until they time out. Postgres itself is nearly idle: low CPU and no slow queries.
GET /healthz keeps returning 204.
3. Application Logs
2026/10/12 09:02:11 reviews service listening on :8080
2026/10/12 09:02:14 top reviews for product 7: context deadline exceeded
2026/10/12 09:02:14 top reviews for product 31: context deadline exceeded
2026/10/12 09:02:14 top reviews for product 12: context deadline exceeded
2026/10/12 09:02:15 top reviews for product 7: context deadline exceeded
2026/10/12 09:02:15 top reviews for product 44: context deadline exceeded
# k6
http_req_failed................: 97.41%
http_req_duration..............: avg=1.96s p(99)=2.01s
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%).
- Performance: P99 latency stays below 200 ms (
p99_latency_ms < 200).
- Data Integrity: All 500 reviews are still in the database (
data_integrity).
Toolbox: curl localhost:8080/products/1/reviews, psql "$DATABASE_URL". 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.