Connection pool exhausted during nightly import
Overview
The API starts returning 500s about ten minutes into the nightly import. Every request is waiting on a free connection.
Error: timeout exceeded when trying to connect
at PoolClient.connect (pg-pool/index.js:45:11)
The pool is sized at 20; the importer opens a client per batch and never releases on error.
- [ ] confirm the leak is on the error path
- [ ] add a release in
finally
Discussion (4)
Sign in to take part in this investigation.
Jakir Hussian@hussian007 Confirmed — the importer never releases on the error path. @jakirhussiandev can you check whether the retry wrapper swallows it?
ts try { await importBatch(client, rows); } catch (error) { // client.release() never runs throw error; }Jakir Hussian@jakirhussiandev It does. Wrapping the batch in
finallyand raising the pool to 40 while we verify.
jakir.dev.iwc007@jakir-dev-iwc007 Root cause
The release is missing on the error path — see
pool.release().It only leaks when a batch throws.
- size the pool at 40
- release in
finally
Raw HTML is not markup here: <script>alert(1)</script>
Refused link: [click](javascript:alert(1)) — real link: the docs
mamtajalam123@mamtajalam123 ddd
Timeline
@jakirhussiandev raised this BLOCK.
@jakirhussiandev assigned it to @hussian007.