Skip to content

server: make HikariCP leak detection configurable#13394

Draft
andrijapanicsb wants to merge 1 commit into
apache:4.22from
andrijapanicsb:hikari-leak-detection-4.22.1.0
Draft

server: make HikariCP leak detection configurable#13394
andrijapanicsb wants to merge 1 commit into
apache:4.22from
andrijapanicsb:hikari-leak-detection-4.22.1.0

Conversation

@andrijapanicsb

Copy link
Copy Markdown
Contributor

server: make HikariCP leak detection configurable

Summary

This change adds optional CloudStack management-server database settings for HikariCP leak detection and JMX MBean registration.

  • Add db.cloud.leakDetectionThreshold support and map it to HikariConfig#setLeakDetectionThreshold(long).
  • Add db.cloud.registerMbeans support and map it to HikariConfig#setRegisterMbeans(boolean).
  • Keep both settings disabled by default.
  • Document disabled-by-default examples in client/conf/db.properties.in.

Motivation

Operators debugging management-server DB pool exhaustion need a runtime-configurable way to identify code paths that borrow JDBC connections and do not return them quickly enough. HikariCP already supports leak-detection stack traces and JMX pool counters, but CloudStack did not expose those options through db.properties.

These settings make it possible to enable leak diagnostics temporarily during investigation without hard-coding a threshold or changing production defaults.

Implementation

  • Parse db.cloud.leakDetectionThreshold as an optional long value alongside the existing cloud DB pool tuning properties.
  • Parse db.cloud.registerMbeans as an optional boolean value.
  • Pass the new values only into the HikariCP datasource configuration path.
  • Leave DBCP behavior unchanged.
  • Apply effective defaults of 0 for leak detection and false for MBean registration.
  • Log the effective HikariCP debug settings at debug level without logging credentials or connection secrets.
  • Add focused TransactionLegacyTest coverage for absent, disabled, enabled leak-detection, and enabled MBean settings.
  • Update existing URI assertions to include the current TransactionLegacy.CONNECTION_PARAMS suffix.

Testing

Ran the following validation:

git diff --check
git grep -n "leakDetectionThreshold\|registerMbeans" -- .
mvn -pl framework/db -am -Dtest=TransactionLegacyTest -DfailIfNoTests=false "-Dsurefire.failIfNoSpecifiedTests=false" test
mvn -pl framework/db -am -DskipTests compile

Results:

  • git diff --check passed.
  • TransactionLegacyTest passed with 12 tests, 0 failures.
  • framework/db compile passed.

Runtime Usage

To enable leak diagnostics after deploying a package built from this branch, set the following in /etc/cloudstack/management/db.properties:

db.cloud.leakDetectionThreshold=60000
db.cloud.registerMbeans=true

Then restart the management server:

systemctl restart cloudstack-management

During reproduction, inspect the management-server log for HikariCP leak-detection output:

grep -i "leak detection\|Apparent connection leak\|ProxyLeakTask\|Hikari" /var/log/cloudstack/management/management-server.log

Signed-off-by: andrijapanicsb andrija.panic@gmail.com

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.89474% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.67%. Comparing base (348ce95) to head (a8812cf).
⚠️ Report is 12 commits behind head on 4.22.

Files with missing lines Patch % Lines
...ain/java/com/cloud/utils/db/TransactionLegacy.java 57.89% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #13394      +/-   ##
============================================
- Coverage     17.68%   17.67%   -0.01%     
+ Complexity    15793    15788       -5     
============================================
  Files          5922     5922              
  Lines        533123   533179      +56     
  Branches      65201    65208       +7     
============================================
- Hits          94268    94245      -23     
- Misses       428212   428288      +76     
- Partials      10643    10646       +3     
Flag Coverage Δ
uitests 3.69% <ø> (ø)
unittests 18.75% <57.89%> (-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.

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