Skip to content

add leak detection for the database connection pools - #14965

Open
Damans227 wants to merge 1 commit into
apache:4.22from
Damans227:hikari-leak-detection-4.22
Open

Damans227 wants to merge 1 commit into
apache:4.22from
Damans227:hikari-leak-detection-4.22

Conversation

@Damans227

Copy link
Copy Markdown
Contributor

There is no way to see which code holds a database connection and never gives it back. The pool just runs out and the error doesnt say who caused it. This adds a leakDetectionThreshold setting for the cloud, usage and simulator pools in db.properties. When a connection stays out longer than that, the pool logs a warning with the stack trace of the code that took it. It is off by default (0). The leak warning gets its own log line in log4j-cloud.xml.in so it still prints if the pool logs are muted. This picks up from #13407, which was closed because the leak logs needed tuning.

Test:

Set db.cloud.leakDetectionThreshold=2000 in db.properties, restart the management server and hold a connection longer than 2 seconds.

Before: no warning, the pool only fails once it runs out.

After: a warning from ProxyLeakTask with the stack trace in management-server.log. Lab results to follow.

@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.33%. Comparing base (89a1f73) to head (29358eb).

Files with missing lines Patch % Lines
...ain/java/com/cloud/utils/db/TransactionLegacy.java 33.33% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #14965      +/-   ##
============================================
- Coverage     18.34%   18.33%   -0.01%     
+ Complexity    16679    16677       -2     
============================================
  Files          5940     5940              
  Lines        537840   537844       +4     
  Branches      65940    65940              
============================================
- Hits          98668    98639      -29     
- Misses       427946   427989      +43     
+ Partials      11226    11216      -10     
Flag Coverage Δ
uitests 4.08% <ø> (ø)
unittests 19.43% <33.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant