More screenshots

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+20 more

    Repair Connection Pool Exhaustion & Recovery

    1

    Diagnose and repair database/HTTP connection pools, acquisition timeouts, leaks, stale connections, resizing, retries, and recovery under load.

    $2.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Repair Connection Pool Exhaustion & Recovery

    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

    MetricObservationRisk
    IdentityTypeORM QueryRunnerManaged manually outside of standard repository flow
    OwnershipMiddleware next() callConnection remains open if downstream handler throws
    InvariantRelease-on-ExitViolated: 12% of requests in logs fail to call release()
    StateisReleased: falseLeads 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

    1. Apply the finally block to the transactionMiddleware to ensure queryRunner.release() is always called.
    2. Monitor the pg_stat_activity view to verify that active connections scale down during idle periods.
    3. Add a unit test using a mock QueryRunner to verify release is called even when next() 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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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

    Listed1 month ago

    What's inside

    Frequently Asked Questions