Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions client/conf/db.properties.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ db.cloud.maxWait=600000
db.cloud.minIdleConnections=5
db.cloud.connectionTimeout=30000
db.cloud.keepAliveTime=600000
# time in ms a connection can stay out before it is logged as a possible leak, 0 turns it off.
# must be at least 2000 and not above maxWait for the same pool, or it is turned off.
db.cloud.leakDetectionThreshold=0
db.cloud.validationQuery=/* ping */ SELECT 1
db.cloud.testOnBorrow=true
db.cloud.testWhileIdle=true
Expand Down Expand Up @@ -81,6 +84,7 @@ db.usage.maxWait=600000
db.usage.minIdleConnections=5
db.usage.connectionTimeout=30000
db.usage.keepAliveTime=600000
db.usage.leakDetectionThreshold=0
db.usage.url.params=serverTimezone=UTC

# Simulator database settings
Expand All @@ -97,6 +101,7 @@ db.simulator.maxWait=600000
db.simulator.minIdleConnections=5
db.simulator.connectionTimeout=30000
db.simulator.keepAliveTime=600000
db.simulator.leakDetectionThreshold=0
db.simulator.autoReconnect=true

# Connection URI to the database "simulator". When this property is set, only the following properties will be used along with it: db.simulator.host, db.simulator.port, db.simulator.name, db.simulator.autoReconnect. Other properties will be ignored.
Expand Down
4 changes: 4 additions & 0 deletions client/conf/log4j-cloud.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ under the License.

<Logger name="org" level="INFO"/>

<!-- Dedicated logger for HikariCP DB connection leak detection so leak stack traces print even if parent
com.zaxxer.hikari logger is later muted -->
<Logger name="com.zaxxer.hikari.pool.ProxyLeakTask" level="INFO"/>

<Logger name="org.springframework" level="WARN"/>

<Logger name="org.apache.cloudstack.spring.module.context.ResourceApplicationContext" level="WARN"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,7 @@ public static void initDataSource(Properties dbProps) {
final Integer cloudMinIdleConnections = parseNumber(dbProps.getProperty("db.cloud.minIdleConnections"), Integer.class);
final Long cloudConnectionTimeout = parseNumber(dbProps.getProperty("db.cloud.connectionTimeout"), Long.class);
final Long cloudKeepAliveTimeout = parseNumber(dbProps.getProperty("db.cloud.keepAliveTime"), Long.class);
final Long cloudLeakDetectionThreshold = parseNumber(dbProps.getProperty("db.cloud.leakDetectionThreshold"), Long.class);
final String cloudUsername = dbProps.getProperty("db.cloud.username");
final String cloudPassword = dbProps.getProperty("db.cloud.password");
final String cloudValidationQuery = dbProps.getProperty("db.cloud.validationQuery");
Expand Down Expand Up @@ -1107,7 +1108,7 @@ public static void initDataSource(Properties dbProps) {
cloudUsername, cloudPassword, cloudMaxActive, cloudMaxIdle, cloudMaxWait,
cloudTimeBtwEvictionRunsMillis, cloudMinEvcitableIdleTimeMillis, cloudTestWhileIdle,
cloudTestOnBorrow, cloudValidationQuery, cloudMinIdleConnections, cloudConnectionTimeout,
cloudKeepAliveTimeout, isolationLevel, "cloud");
cloudKeepAliveTimeout, cloudLeakDetectionThreshold, isolationLevel, "cloud");

// Configure the usage db
final Integer usageMaxActive = parseNumber(dbProps.getProperty("db.usage.maxActive"), Integer.class);
Expand All @@ -1116,6 +1117,7 @@ public static void initDataSource(Properties dbProps) {
final Integer usageMinIdleConnections = parseNumber(dbProps.getProperty("db.usage.minIdleConnections"), Integer.class);
final Long usageConnectionTimeout = parseNumber(dbProps.getProperty("db.usage.connectionTimeout"), Long.class);
final Long usageKeepAliveTimeout = parseNumber(dbProps.getProperty("db.usage.keepAliveTime"), Long.class);
final Long usageLeakDetectionThreshold = parseNumber(dbProps.getProperty("db.usage.leakDetectionThreshold"), Long.class);
final String usageUsername = dbProps.getProperty("db.usage.username");
final String usagePassword = dbProps.getProperty("db.usage.password");

Expand All @@ -1127,7 +1129,7 @@ public static void initDataSource(Properties dbProps) {
s_usageDS = createDataSource(dbProps.getProperty("db.usage.connectionPoolLib"), usageUriAndDriver.first(),
usageUsername, usagePassword, usageMaxActive, usageMaxIdle, usageMaxWait, null,
null, null, null, null,
usageMinIdleConnections, usageConnectionTimeout, usageKeepAliveTimeout, isolationLevel, "usage");
usageMinIdleConnections, usageConnectionTimeout, usageKeepAliveTimeout, usageLeakDetectionThreshold, isolationLevel, "usage");

try {
// Configure the simulator db
Expand All @@ -1137,6 +1139,7 @@ public static void initDataSource(Properties dbProps) {
final Integer simulatorMinIdleConnections = parseNumber(dbProps.getProperty("db.simulator.minIdleConnections"), Integer.class);
final Long simulatorConnectionTimeout = parseNumber(dbProps.getProperty("db.simulator.connectionTimeout"), Long.class);
final Long simulatorKeepAliveTimeout = parseNumber(dbProps.getProperty("db.simulator.keepAliveTime"), Long.class);
final Long simulatorLeakDetectionThreshold = parseNumber(dbProps.getProperty("db.simulator.leakDetectionThreshold"), Long.class);
final String simulatorUsername = dbProps.getProperty("db.simulator.username");
final String simulatorPassword = dbProps.getProperty("db.simulator.password");

Expand Down Expand Up @@ -1167,7 +1170,7 @@ public static void initDataSource(Properties dbProps) {
simulatorConnectionUri, simulatorUsername, simulatorPassword, simulatorMaxActive,
simulatorMaxIdle, simulatorMaxWait, null, null, null, null,
cloudValidationQuery, simulatorMinIdleConnections, simulatorConnectionTimeout,
simulatorKeepAliveTimeout, isolationLevel, "simulator");
simulatorKeepAliveTimeout, simulatorLeakDetectionThreshold, isolationLevel, "simulator");
} catch (Exception e) {
LOGGER.debug("Simulator DB properties are not available. Not initializing simulator DS");
}
Expand Down Expand Up @@ -1269,21 +1272,21 @@ protected static String buildConnectionUri(String loadBalanceStrategy, String dr
private static DataSource createDataSource(String connectionPoolLib, String uri, String username, String password,
Integer maxActive, Integer maxIdle, Long maxWait, Long timeBtwnEvictionRuns, Long minEvictableIdleTime,
Boolean testWhileIdle, Boolean testOnBorrow, String validationQuery, Integer minIdleConnections,
Long connectionTimeout, Long keepAliveTime, Integer isolationLevel, String dsName) {
Long connectionTimeout, Long keepAliveTime, Long leakDetectionThreshold, Integer isolationLevel, String dsName) {
LOGGER.debug("Creating datasource for database: {} with connection pool lib: {}", dsName,
connectionPoolLib);
if (CONNECTION_POOL_LIB_DBCP.equals(connectionPoolLib)) {
return createDbcpDataSource(uri, username, password, maxActive, maxIdle, maxWait, timeBtwnEvictionRuns,
minEvictableIdleTime, testWhileIdle, testOnBorrow, validationQuery, isolationLevel);
}
return createHikaricpDataSource(uri, username, password, maxActive, maxIdle, maxWait, minIdleConnections,
connectionTimeout, keepAliveTime, isolationLevel, dsName);
connectionTimeout, keepAliveTime, leakDetectionThreshold, isolationLevel, dsName);
}

private static DataSource createHikaricpDataSource(String uri, String username, String password,
Integer maxActive, Integer maxIdle, Long maxWait,
Integer minIdleConnections, Long connectionTimeout, Long keepAliveTime,
Integer isolationLevel, String dsName) {
Long leakDetectionThreshold, Integer isolationLevel, String dsName) {
HikariConfig config = new HikariConfig();
config.setJdbcUrl(uri);
config.setUsername(username);
Expand All @@ -1298,6 +1301,7 @@ private static DataSource createHikaricpDataSource(String uri, String username,
config.setMinimumIdle(ObjectUtils.defaultIfNull(minIdleConnections, 5));
config.setConnectionTimeout(ObjectUtils.defaultIfNull(connectionTimeout, 30000L));
config.setKeepaliveTime(ObjectUtils.defaultIfNull(keepAliveTime, 600000L));
config.setLeakDetectionThreshold(ObjectUtils.defaultIfNull(leakDetectionThreshold, 0L));

String isolationLevelString = "TRANSACTION_READ_COMMITTED";
if (isolationLevel == Connection.TRANSACTION_SERIALIZABLE) {
Expand Down
3 changes: 3 additions & 0 deletions usage/conf/db.properties.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ db.usage.maxWait=10000
db.usage.minIdleConnections=5
db.usage.connectionTimeout=30000
db.usage.keepAliveTime=600000
# time in ms a connection can stay out before it is logged as a possible leak, 0 turns it off.
# must be at least 2000 and not above maxWait for the same pool, or it is turned off.
db.usage.leakDetectionThreshold=0
db.usage.autoReconnect=true
Loading