shwstppr commented on code in PR #9518:
URL: https://github.com/apache/cloudstack/pull/9518#discussion_r1732237338


##########
framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java:
##########
@@ -1226,45 +1220,84 @@ private static DataSource createDataSource(String uri, 
String username, String p
                                                Integer maxActive, Integer 
maxIdle, Long maxWait,
                                                Long timeBtwnEvictionRuns, Long 
minEvictableIdleTime,
                                                Boolean testWhileIdle, Boolean 
testOnBorrow,
-                                               String validationQuery, Integer 
isolationLevel) {
-        ConnectionFactory connectionFactory = new 
DriverManagerConnectionFactory(uri, username, password);
-        PoolableConnectionFactory poolableConnectionFactory = new 
PoolableConnectionFactory(connectionFactory, null);
-        GenericObjectPoolConfig config = createPoolConfig(maxActive, maxIdle, 
maxWait, timeBtwnEvictionRuns, minEvictableIdleTime, testWhileIdle, 
testOnBorrow);
-        ObjectPool<PoolableConnection> connectionPool = new 
GenericObjectPool<>(poolableConnectionFactory, config);
-        poolableConnectionFactory.setPool(connectionPool);
-        if (validationQuery != null) {
-            poolableConnectionFactory.setValidationQuery(validationQuery);
+                                               String validationQuery, Integer 
isolationLevel,
+                                               String dsName) {
+        HikariConfig config = new HikariConfig();
+        config.setJdbcUrl(uri);
+        config.setUsername(username);
+        config.setPassword(password);
+
+        config.setPoolName(dsName);
+        if (maxActive != null) {
+            config.setMaximumPoolSize(maxActive);
+        } else {
+            config.setMaximumPoolSize(250); // 250 connections
         }
-        if (isolationLevel != null) {
-            
poolableConnectionFactory.setDefaultTransactionIsolation(isolationLevel);
+        if (maxIdle != null) {
+            config.setIdleTimeout(maxIdle * 1000);
+        } else {
+            config.setIdleTimeout(30000); // 30 seconds
         }
-        return new PoolingDataSource<>(connectionPool);
-    }
-
-    /**
-     * Return a GenericObjectPoolConfig configuration usable on connection 
pool creation
-     */
-    private static GenericObjectPoolConfig createPoolConfig(Integer maxActive, 
Integer maxIdle, Long maxWait,
-                                                            Long 
timeBtwnEvictionRuns, Long minEvictableIdleTime,
-                                                            Boolean 
testWhileIdle, Boolean testOnBorrow) {
-        GenericObjectPoolConfig config = new GenericObjectPoolConfig();
-        config.setMaxTotal(maxActive);
-        config.setMaxIdle(maxIdle);
-        config.setMaxWaitMillis(maxWait);
+        if (maxWait != null) {
+            config.setMaxLifetime(maxWait);
+        } else {
+            config.setMaxLifetime(600000); // 10 minutes
+        }
+
+        // Connection pool properties
+        config.setMinimumIdle(5);           // Minimum number of idle 
connections in the pool
+        config.setConnectionTimeout(30000); // 30 seconds in milliseconds
+        config.setKeepaliveTime(600000);    // Keepalive time in milliseconds 
(10 minutes)
+        config.setIdleTimeout(300000); // 5 minutes
+        //config.setMinimumIdle(maxIdle);

Review Comment:
   @rohityadavcloud sure, will check and move them to db.properties.
   Currently looking into failure while setting simulator CI env in GH actions. 
Getting errors like,
   
   ```
    Error:  Failed to execute goal 
org.codehaus.mojo:exec-maven-plugin:1.2.1:java (create-schema) on project 
cloud-developer: An exception occured while executing the Java class. null: 
InvocationTargetException: Unable to upgrade the database: Unable to execute 
upgrade script: Expression #47 of SELECT list is not in GROUP BY clause and 
contains nonaggregated column 'cloud.offering_details.value' which is not 
functionally dependent on columns in GROUP BY clause; this is incompatible with 
sql_mode=only_full_group_by -> [Help 1]
   ```



-- 
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: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to