Connection Leak Detection

Tools and patterns.

Overview

Connection leak detection catches applications that fail to return database or HTTP connections to the pool. Each leak ties up a connection that the pool will never reclaim; eventually the pool exhausts and every request blocks waiting for a connection that no longer exists. The discipline is in framework-level leak detection (HikariCP’s leakDetectionThreshold, Pgx pool diagnostics), pool monitoring with depth alerts, and per-codepath tracing to find which call site is failing to release.

The approach

The practical approach is to monitor pool utilization and queue depth as first-class metrics, set per-connection age thresholds that trigger leak alerts, enable framework-level leak detection (HikariCP leakDetectionThreshold and equivalent), trace per-codepath connection acquisition so the leaking call site is identifiable, and document the per-service leak threshold so the rules are predictable.

Why this compounds

Connection leak discipline compounds across services. Each leak caught early prevents an incident the team would otherwise debug at 3am; each framework-level detector teaches the team where their connection-acquisition patterns are fragile; the operational maturity to catch leaks before they exhaust the pool grows quarter over quarter.

Connection leak detection is an operational discipline that pays off across years. Nova AI Ops integrates with pool telemetry, surfaces leak patterns, and supports the team’s application discipline.