Debug a latency spike The query that started too late The order screen spins for nearly a second. The database engineer opens the query log and finds a fast lookup. Both observations can be true. Jo puts a clock at the entrance to checkout and another at the moment a worker actually obtains its database connection. A worker borrows a connection, runs its query and returns the lease so someone else can use it. In the healthy interval here, the ninety-ninth percentile for acquiring a connection is four milliseconds. The timer stops before the query executes. Traffic stays comparable after a release, but pool wait at the ninety-ninth percentile climbs to seven hundred ninety milliseconds. The query timer barely moves. Customers pay for that wait even though the database has no running query to report for them yet. Checkout in context End-to-end latency includes queueing before work starts, service time, network transfer and scheduling. Parallel child spans can overlap, so adding every span duration can exceed request time. Follow the critical path and identify the longest avoidable interval before interpreting a slow request as a slow database. Draw three timestamps for one checkout. It reaches the service. It obtains a database connection. The database returns its first row. A server that times only the last interval can truthfully report fast queries while users see slow pages. Measure the waiting interval at the caller that is trying to borrow the connection. Find the missing interval Jo lines up one checkout trace. The request reaches the application, enters the acquisition queue, borrows a connection and only then sends the query. She marks which activity occupies the gap between the checkout start and the query start. Some checkouts also fetch pricing and delivery estimates in parallel. Adding every child span duration would count their overlap twice. Jo follows the sequence of dependent events that actually delayed the response. On these slow traces the blocking acquisition is on that path. The older workers return their connections. On the new workers the checked-out count stays high after a particular error path. The pool's population is bounded. If a lease never comes back, its slot cannot serve the next customer. Consider a second possible leak. One branch returns early on a cancelled checkout without releasing its lease. The number of borrowed connections slowly climbs even when query duration stays constant. Instrument acquisition and release with the same lease identity on a test worker. An unmatched borrow after the cancellation has completed is concrete evidence. For a normal long-running query there should eventually be a matching release. That difference is more diagnostic than adding a larger pool and observing a temporary reprieve. Read the measurements Imagine one worker holds a connection while calling an unrelated shipping service. Other workers arrive, see a full pool, and wait. The database itself may be lightly loaded. Track ownership from checkout to release. If a worker holds the connection across that remote call, test reducing the holding interval in a canary before raising a fleet-wide limit. Imagine a two-second deadline. Waiting eight tenths of a second for a connection and another second for the database consumes almost all of it. DNS, a downstream request or a retry now has little room left. Record the remaining budget on entry to each stage. A modest rise in one stage can trigger a large jump in final timeouts. Choose a test with different predictions Which change addresses the missing interval? An index can reduce time spent executing a query. A larger pool can admit more connections. Returning a retained lease makes the same connection available again. Only one directly repairs the observed ownership error. Jo exercises the ordinary error-handling path in a safe test environment and checks that the release returns the lease even when the request fails. That check distinguishes a cleanup problem from a database that really is running longer under load. If pool waits had stayed short while query execution grew, she'd compare plans and parameter mix at the same endpoint. Increasing concurrency on an already busy database could make a genuine execution bottleneck worse. Check the competing explanation At the same request rate, checkout ninety-ninth percentile rises while query execution time barely changes. Trace the time before the query starts. Compare checked-out connections, pool wait and downstream limits by release. Increasing pool size may worsen database contention. Restoring a leaked lease or limiting fan-out can shorten the queue without increasing database concurrency. A slow trace selected because it exceeded the deadline is evidence about the tail. To estimate overall impact, ask how many requests entered the path, how many missed the deadline, and which cohorts account for the difference. Comparing only slow traces from the two releases makes both appear equally bad by construction. Reopen the same clocks With the cleanup repaired at matched traffic, pool wait at the ninety-ninth percentile drops to seven milliseconds. Jo checks the checkout tail separately. A shorter wait should help users, but a downstream regression could still delay the final response. The database log described the time after the query began. The customer had been waiting well before that. The durable improvement is a pair of separate timers and a test that checks lease ownership on every exit path. Apply the diagnosis Now the pool has free slots and the waiting interval persists. What would change your mind? Check per-process pools, queue fairness and the interval your instrumentation actually measures. A global free-slot gauge can hide a full worker-local pool. Match one patient request to its own pool instance before you conclude the gauge contradicts the trace.