Metastable failure debugging lab. Postgres stalled for ten seconds and recovered. The search API is still timing out, at the same traffic as before.
Practice debugging a metastable failure in a live, broken production system in your browser, with Go and 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.
> Go only. This stack is about how a Go service behaves under load, so it ships in Go alone.
1. The Incident Context
At 21:00 Postgres froze for 10 seconds during a storage failover. It came back fully, and its metrics have been calm ever since. The search API did not come back. It still answers almost nothing but timeouts, at the same traffic it handled fine before. Last time it only recovered when someone blocked all traffic for a minute. Clients are not sending any more searches than usual.
2. Observed Symptoms & Metrics
- Affected Endpoints / Components:
GET /search?q=... on the search service, the mobile and web clients, Postgres listings table.
- Behavior: Before the stall, a search takes about 40 ms at 80 fresh searches a second, and the database can handle about 125 a second. After the stall, almost every search times out, minute after minute. Restarting the service fixes it until the next database hiccup.
- Error Rate: Over 95% of searches time out at the clients' 1 s limit, long after the database is healthy again.
- System Metrics: The database is busy the whole time, and each query on its own is fast. The service exposes
queue_depth, incoming_total, served_total and goodput_total (responses that reached a client still waiting) on /metrics. Goodput is near zero while the service stays busy.
3. Application Logs
2026/10/12 21:00:00 search service listening on :8080, workers=5
2026/10/12 21:00:30 db: stall injected for 10s
2026/10/12 21:00:40 db: stall cleared
2026/10/12 21:05:00 queue_depth=6211 served_rps=124 goodput_rps=2 incoming_rps=301
2026/10/12 21:05:02 search "lamp": client went away after 1s: write: broken pipe
# k6
failed_operations..............: 96.20%
http_reqs......................: 36.1k 301/s
4. Your Objective
Step into the live environment while synthetic traffic is running, diagnose the root cause, and patch the codebase. The load generator triggers a 10-second database stall 45 seconds after it starts.
To clear this stack, your fix must pass these automated checks during a 2-minute run of 80 fresh searches a second from the simulated clients, with a 10-second database stall at second 30:
- Recovery: From 10 seconds after the stall ends, at least 95% of fresh searches succeed on their first try (
post_recovery_misses < 5%).
- Error Rate: Over the whole run, fewer than 8% of client searches fail after all their retries. This leaves room for the stall itself (
failed_operations < 8%).
- Performance: P99 latency of successful requests stays below 400 ms outside the stall window (
ok_ms p99 < 400).
- Fairness: Requests the service turns away get a
429 or 503 with a Retry-After header, within 20 ms (shed_ms p99 < 20, checks_fails == 0).
Environment note: you may change the server only. The clients give up after 1 s, retry up to 3 times, and respect Retry-After. Each request carries the client's deadline in an X-Request-Deadline header (Unix ms). The database's speed is fixed.
Toolbox: curl localhost:8080/metrics, curl 'localhost:8080/search?q=lamp', curl -X POST localhost:9090/stall -d '{"seconds": 10}' (stall the database), curl localhost:9090/stats, psql "$DATABASE_URL", htop. Save a file in the editor to rebuild and restart the app. Click Verify when you think it's fixed.
Terms in this lab: p99, goodput (responses that reach a client before it gives up), Retry-After (response header telling the client how many seconds to wait), 429 / 503 (Too Many Requests / Service Unavailable), stall (the database stops answering for a while), k6.
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.
This site needs JavaScript to run labs.