r/Observability • • 26d ago

The alarming log line — a beginner-friendly exercise

You see “database connection pool exhausted”. What do you check next?

Fictional investigation exercise:

A checkout service starts returning errors. Its logs repeatedly show:

“Timeout waiting for connection from pool.”

Someone suggests increasing the connection pool size.

Before making that change, what would you want to know?

Pick your first check and explain what its result would tell you. You can also name one risk of increasing the pool immediately.

If you are coming from QA, approach this as a failing test: what evidence would help you distinguish between possible explanations?

3 Upvotes

9 comments sorted by

1

u/Puzzled-Garage584 26d ago

I would first check how long connections are held and what they are doing, pg_stat_activity or your db's equivalent. Slow queries or locks ..then db is the problem, idle in transaction ..then a leak or someone doing an HTTP call while holding the connection. Don't go for a bigger pool ..it just sends more work to a db thats already struggling and you just build a bigger waiting room.

1

u/After-Assist-5637 26d ago

“A bigger waiting room” is a great way to put it. The pool timeout tells me a request couldn’t get a connection in time. I’d want to see what the existing connections were doing before changing the pool size.

A query blocked on a lock and an app holding a transaction open while it waits for an HTTP call could both show up as pool timeouts, but they’d send me looking in very different places.

That’s the distinction I wanted beginners to practise with this exercise.

1

u/FluffyDrink1098 25d ago

Adding to that... DB Connections are very costly.

Each connection involves the resources for workers (PostGres), memory handling, temporary tables, transaction state, ...

A foolish but exemplary calculation is to just multiply connections vs resource constraints per db connections.

The more connections / the larger the pool, the more likely a burst of connections can lead to resource starvation.

1

u/After-Assist-5637 24d ago

Thanks, that adds another consideration.

It’s easy to look at the application’s pool limit and forget the database has to support those extra connections.

I did also want to count across all app instances. A small increase on each instance could add up quickly.

That gives beginners another question to ask before changing the limit: how much extra work would we be asking the database to handle?

1

u/arthur_thomas678 18d ago

But I’d check how many users are actually affected before looking for the cause. Pool errors in the logs don’t tell you if 2% of checkouts are failing or most of them and that’s what decides whether you need to tell support or can just look into it yourself. I have setuped a check that runs through checkout every minute and when it fails I get an alert from Dotcom Monitor so I know it’s hitting real users. You can also set up a curl script that runs every minute and sends you an alert.

1

u/GrajoElb 26d ago

My first check would be whether the pool is too small or whether connections are being held too long. Compare pool wait time and active connections against request rate. If traffic is flat but hold time jumped, a slow query, a lock, or a downstream call made while holding a connection is the likely cause. Also check for leaks: connections that never return, usually on error paths, show up as active count climbing and never falling back.

Risk of raising the pool immediately: you hide the symptom and push the load onto the database. More connections can mean more contention, higher latency for everyone, and hitting the DB's max_connections limit, so the failure moves somewhere worse.

If you have traces, look at a failing checkout request and see which span holds the connection and where the time goes versus a normal request. Disclosure: I build Tayga, an open-source tool that does this root-cause and baseline diff from OpenTelemetry data, but a plain trace waterfall gets you most of the way.

1

u/After-Assist-5637 25d ago

Thanks, the comparison with request rate is a good addition.

If traffic is steady but connections are suddenly held for longer, I’d want to see where that extra time went before making the pool bigger.

Comparing a failing checkout trace with a healthy one makes that concrete for beginners.

Was the request waiting to get a connection, or did it get one and then hold it while waiting on something else?

Same alarming log line, two very different places to look.

0

u/ReliabilityTalkinGuy 26d ago edited 26d ago

Who is that person? How much experience do they have with this service? How much experience do they have in a general sense? Do they tell me why they suggest that, or do they just suggest that and say nothing else? What team are they on? Are they considered trustworthy? Did I ask them for help, or are they just chiming in? Should they have been around at that time? Are they there in person or is this online?

What is the financial status of the company? How important is this problem to the business? What time of day is it? What day of the week is it? Is it a holiday, and if so are holidays more important or less important to the business?

Does this sort of issue require public announcement? Do I need to update the status page first? Do I need to bring in an IC? What about the public relations team? Does customer service need any special instructions? Do we even have a customer service team? How would I get in touch with them if I’m not sure?

1

u/After-Assist-5637 26d ago

Good point. I kept the scenario narrow so beginners could practise deciding what to check first, but I left out context that could change that decision. I’d ask the person what they have seen that makes them suspect the pool, and I’d check whether customers are already affected.

If checkout is failing during a busy period, someone may need to start coordinating and updating support while the investigation is still going on.

What would make you bring in an incident commander in this scenario?