andrijapanicsb opened a new pull request, #13394:
URL: https://github.com/apache/cloudstack/pull/13394

   # 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:
   
   ```text
   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`:
   
   ```properties
   db.cloud.leakDetectionThreshold=60000
   db.cloud.registerMbeans=true
   ```
   
   Then restart the management server:
   
   ```bash
   systemctl restart cloudstack-management
   ```
   
   During reproduction, inspect the management-server log for HikariCP 
leak-detection output:
   
   ```bash
   grep -i "leak detection\|Apparent connection leak\|ProxyLeakTask\|Hikari" 
/var/log/cloudstack/management/management-server.log
   ```
   
   Signed-off-by: andrijapanicsb <[email protected]>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to