- Home
- Skills
- Data Engineering
- Repair Connection Pool Exhaustion & Recovery
More screenshots
Works with the AI tools you already use
Repair Connection Pool Exhaustion & Recovery
Diagnose and repair database/HTTP connection pools, acquisition timeouts, leaks, stale connections, resizing, retries, and recovery under load.
$8.99
Repair Connection Pool Exhaustion & Recovery
Example session with this skill installed
Our Postgres pool in TypeORM is hitting the 10-connection limit under load, but CPU is low. I suspect a leak in the transaction middleware. Here is the snippet.
- Read your context and instructions
- Compiled the repair connection pool
I have analyzed the transaction middleware snippet. The issue is a missing finally block in the custom db-transaction decorator, which fails to release connections when an error occurs during the commit phase.
Connection Pool Diagnosis
| Metric | Observation | Risk |
|---|---|---|
| Identity | TypeORM QueryRunner | Managed manually outside of standard repository flow |
| Ownership | Middleware next() call | Connection remains open if downstream handler throws |
| Invariant | Release-on-Exit | Violated: 12% of requests in logs fail to call release() |
| State | isReleased: false | Leads to pool exhaustion within 400 requests |
Proposed Repair
// middleware/transaction.ts
import { Request, Response, NextFunction } from 'express';
import { DataSource } from 'typeorm';
export const transactionMiddleware = (dataSource: DataSource) => {
return async (req: Request, res: Response, next: NextFunction) => {
const queryRunner = dataSource.createQueryRunner();
await queryRunner.connect();
await queryRunner.startTransaction();
try {
(req as any).transactionManager = queryRunner.manager;
await next();
if (queryRunner.isTransactionActive) {
await queryRunner.commitTransaction();
}
} catch (err) {
if (queryRunner.isTransactionActive) {
await queryRunner.rollbackTransaction();
}
throw err;
} finally {
// FIX: Ensure connection returns to pool regardless of outcome
if (!queryRunner.isReleased) {
await queryRunner.release();
}
}
};
};
Next steps
- Apply the
finallyblock to thetransactionMiddlewareto ensurequeryRunner.release()is always called. - Monitor the
pg_stat_activityview to verify that active connections scale down during idle periods. - Add a unit test using a mock
QueryRunnerto verifyreleaseis called even whennext()throws an exception.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
Repair Connection Pool Exhaustion & Recovery is a bounded ToolForge Labs workflow. Diagnose and repair database/HTTP connection pools, acquisition timeouts, leaks, stale connections, resizing, retries, and recovery under load. Works from full repositories or partial context such as snippets, logs, configuration, traces, and architecture notes. Produces concrete repairs or evidence-backed review outputs while preserving existing product/security policy.
It works from a full repository or partial evidence such as snippets, logs, configuration, traces, tickets, and architecture notes. The skill preserves existing product and security policy, separates verified facts from assumptions, avoids invented execution claims, and produces concrete repair or review steps with focused deterministic validation or traceable evidence.
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean today
- Passed all security checks, Safe to install