Skip to content

features/sql: add a leak detection threshold for the connection pool - #627

Merged
cportele merged 1 commit into
masterfrom
leak-detection-threshold
Sep 2, 2026
Merged

features/sql: add a leak detection threshold for the connection pool#627
cportele merged 1 commit into
masterfrom
leak-detection-threshold

Conversation

@cportele

Copy link
Copy Markdown
Contributor

Adds connectionInfo.pool.leakDetectionThreshold for SQL feature providers, exposing HikariCP's
leak detection as a diagnostic option (off by default).

connectionInfo:
  pool:
    maxConnections: 4
    leakDetectionThreshold: 60s

When a connection has been out of the pool for longer than the threshold, HikariCP logs a warning
with the stack trace of the code that leased it; if the connection is returned after all, a second
message follows, so a slow request can be told from a leak (a leak only ever produces the first
message). Minimum 2 s (HikariCP disables smaller values with a warning); the value is checked for
equality when a pool is shared between providers. The messages come from the logger
com.zaxxer.hikari (WARN for the report, INFO for the return message) — a logging
configuration that restricts third-party loggers has to let them through; ldproxy's default does.

This is a diagnostic, not a remedy: a leaked connection stays leaked until restart, and long-running
requests (large exports, big transactions) legitimately hold a connection, so the value should sit
above the longest expected request. Motivated by ldproxy/ldproxy#1761, where the borrower's stack
trace would have pinpointed the leaking path directly.

connectionInfo.pool.leakDetectionThreshold enables HikariCP's leak
detection: a connection out of the pool for longer than the threshold is
logged with the stack trace of the code that leased it, and a second
message follows if it is returned after all. Off by default; the value has
to be at least 2s and is checked for equality when a pool is shared.
@cportele
cportele requested a review from azahnen as a code owner August 29, 2026 13:46
@cportele
cportele merged commit eee2232 into master Sep 2, 2026
3 checks passed
@cportele
cportele deleted the leak-detection-threshold branch September 2, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants