From 0173bbd296cabaf8217798de2a77f0ad0e0feee1 Mon Sep 17 00:00:00 2001 From: Jasper Siepkes Date: Mon, 26 Sep 2022 09:45:05 +0200 Subject: [PATCH] Fixed user defined JDBC URL override not working. (#1499) Fixes logic error in the way a user defined `jdbcUrl` in `hikaricp.properties` is handled. Additionally changed the default max pool size to the previous limit of 90 connections. PR #926 originally also had this but this apparantly fell out. Testing showed that during first time server startup a flood of connection can be made and a connection pool of 30 can be overwhelmed and callers waiting on a connection will time-out. --- .../META-INF/pool/server.default.properties | 4 ++-- .../src/org/compiere/db/DB_Oracle.java | 6 +++--- .../META-INF/pool/server.default.properties | 4 ++-- .../src/org/compiere/db/DB_PostgreSQL.java | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/org.compiere.db.oracle.provider/META-INF/pool/server.default.properties b/org.compiere.db.oracle.provider/META-INF/pool/server.default.properties index cfb50b4a88..02fc862ed5 100644 --- a/org.compiere.db.oracle.provider/META-INF/pool/server.default.properties +++ b/org.compiere.db.oracle.provider/META-INF/pool/server.default.properties @@ -52,7 +52,7 @@ connectionTimeout=60000 # will block for up to connectionTimeout milliseconds before timing out. Please # read about pool sizing: https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing # Default: 10 -maximumPoolSize=30 +maximumPoolSize=90 # This property controls the maximum lifetime of a connection in the pool. An # in-use connection will never be retired, only when it is closed will it then be @@ -69,4 +69,4 @@ maximumPoolSize=30 # pool before a message is logged indicating a possible connection leak. A value of 0 # means leak detection is disabled. Lowest acceptable value for enabling leak detection # is 2000 (2 seconds). Default: 0 -leakDetectionThreshold=300000 \ No newline at end of file +leakDetectionThreshold=300000 diff --git a/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java b/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java index fcc45ba708..8be02c361c 100644 --- a/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java +++ b/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java @@ -721,13 +721,13 @@ public class DB_Oracle implements AdempiereDatabase Properties poolProperties = getPoolProperties(); // Do not override values which might have been read from the users // hikaricp.properties file. - if(!poolProperties.contains("jdbcUrl")) { + if(!poolProperties.containsKey("jdbcUrl")) { poolProperties.put("jdbcUrl", getConnectionURL(connection)); } - if (!poolProperties.contains("username")) { + if (!poolProperties.containsKey("username")) { poolProperties.put("username", connection.getDbUid()); } - if (!poolProperties.contains("password")) { + if (!poolProperties.containsKey("password")) { poolProperties.put("password", connection.getDbPwd()); } diff --git a/org.compiere.db.postgresql.provider/META-INF/pool/server.default.properties b/org.compiere.db.postgresql.provider/META-INF/pool/server.default.properties index cfb50b4a88..02fc862ed5 100644 --- a/org.compiere.db.postgresql.provider/META-INF/pool/server.default.properties +++ b/org.compiere.db.postgresql.provider/META-INF/pool/server.default.properties @@ -52,7 +52,7 @@ connectionTimeout=60000 # will block for up to connectionTimeout milliseconds before timing out. Please # read about pool sizing: https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing # Default: 10 -maximumPoolSize=30 +maximumPoolSize=90 # This property controls the maximum lifetime of a connection in the pool. An # in-use connection will never be retired, only when it is closed will it then be @@ -69,4 +69,4 @@ maximumPoolSize=30 # pool before a message is logged indicating a possible connection leak. A value of 0 # means leak detection is disabled. Lowest acceptable value for enabling leak detection # is 2000 (2 seconds). Default: 0 -leakDetectionThreshold=300000 \ No newline at end of file +leakDetectionThreshold=300000 diff --git a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java index f67fc57694..1b93587680 100755 --- a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java +++ b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java @@ -747,13 +747,13 @@ public class DB_PostgreSQL implements AdempiereDatabase Properties poolProperties = getPoolProperties(); // Do not override values which might have been read from the users // hikaricp.properties file. - if(!poolProperties.contains("jdbcUrl")) { + if(!poolProperties.containsKey("jdbcUrl")) { poolProperties.put("jdbcUrl", getConnectionURL(connection)); } - if (!poolProperties.contains("username")) { + if (!poolProperties.containsKey("username")) { poolProperties.put("username", connection.getDbUid()); } - if (!poolProperties.contains("password")) { + if (!poolProperties.containsKey("password")) { poolProperties.put("password", connection.getDbPwd()); }