- Home
- Skills
- Data & Databases
- Repair Connection Pool Exhaustion & Recovery
More screenshots
Works with the AI Agents 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.
$2.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.
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 use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 1 month ago