You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by vo...@apache.org on 2020/03/28 16:58:52 UTC
[fineract] 02/02: apply Hikari's recommended MySQL Configuration
(FINERACT-796)
This is an automated email from the ASF dual-hosted git repository.
vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
commit 53e8658d74604acaf6e3b959f2431c31f7c0d867
Author: Michael Vorburger <mi...@vorburger.ch>
AuthorDate: Sat Mar 28 15:06:15 2020 +0100
apply Hikari's recommended MySQL Configuration (FINERACT-796)
from https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
and https://github.com/brettwooldridge/HikariCP/wiki/JDBC-Logging#mysql-connectorj
---
.../TomcatJdbcDataSourcePerTenantService.java | 21 +++++++++++++++++++++
.../resources/META-INF/spring/hikariDataSource.xml | 13 +++++++++----
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TomcatJdbcDataSourcePerTenantService.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TomcatJdbcDataSourcePerTenantService.java
index 48a2bbb..71be36e 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TomcatJdbcDataSourcePerTenantService.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TomcatJdbcDataSourcePerTenantService.java
@@ -86,11 +86,32 @@ public class TomcatJdbcDataSourcePerTenantService implements RoutingDataSourceSe
config.setJdbcUrl(jdbcUrl);
config.setUsername(tenantConnectionObj.getSchemaUsername());
config.setPassword(tenantConnectionObj.getSchemaPassword());
+ config.setMinimumIdle(tenantConnectionObj.getInitialSize());
+ config.setMaximumPoolSize(tenantConnectionObj.getMaxActive());
config.setConnectionTestQuery("SELECT 1");
config.setValidationTimeout(tenantConnectionObj.getValidationInterval());
config.setAutoCommit(true);
+ // https://github.com/brettwooldridge/HikariCP/wiki/MBean-(JMX)-Monitoring-and-Management
+ config.setRegisterMbeans(true);
+
// https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
+ // These are the properties for each Tenant DB; the same configuration is also in src/main/resources/META-INF/spring/hikariDataSource.xml for the all Tenants DB -->
+ config.addDataSourceProperty("cachePrepStmts", "true");
+ config.addDataSourceProperty("prepStmtCacheSize", "250");
+ config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
+ config.addDataSourceProperty("useServerPrepStmts", "true");
+ config.addDataSourceProperty("useLocalSessionState", "true");
+ config.addDataSourceProperty("rewriteBatchedStatements", "true");
+ config.addDataSourceProperty("cacheResultSetMetadata", "true");
+ config.addDataSourceProperty("cacheServerConfiguration", "true");
+ config.addDataSourceProperty("elideSetAutoCommits", "true");
+ config.addDataSourceProperty("maintainTimeStats", "false");
+
+ // https://github.com/brettwooldridge/HikariCP/wiki/JDBC-Logging#mysql-connectorj
+ config.addDataSourceProperty("logger", "com.mysql.jdbc.log.StandardLogger");
+ config.addDataSourceProperty("logSlowQueries", "true");
+ config.addDataSourceProperty("dumpQueriesOnException", "true");
return new HikariDataSource(config);
}
diff --git a/fineract-provider/src/main/resources/META-INF/spring/hikariDataSource.xml b/fineract-provider/src/main/resources/META-INF/spring/hikariDataSource.xml
index 1ee2108..1ba0ba0 100644
--- a/fineract-provider/src/main/resources/META-INF/spring/hikariDataSource.xml
+++ b/fineract-provider/src/main/resources/META-INF/spring/hikariDataSource.xml
@@ -44,21 +44,26 @@
<property name="idleTimeout" value="60000" />
<property name="ConnectionTestQuery" value="SELECT 1" />
- <!-- https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration -->
+ <!-- These are the properties for the all Tenants DB; the same configuration is also (hard-coded) in the TomcatJdbcDataSourcePerTenantService class -->
<property name="dataSourceProperties">
<props>
+ <!-- https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration -->
<prop key="cachePrepStmts">true</prop>
<prop key="prepStmtCacheSize">250</prop>
<prop key="prepStmtCacheSqlLimit">2048</prop>
<prop key="useServerPrepStmts">true</prop>
<prop key="useLocalSessionState">true</prop>
-
<prop key="rewriteBatchedStatements">true</prop>
<prop key="cacheResultSetMetadata">true</prop>
<prop key="cacheServerConfiguration">true</prop>
<prop key="elideSetAutoCommits">true</prop>
- <prop key="maintainTimeStats">true</prop>
+ <prop key="maintainTimeStats">false</prop>
+
+ <!-- https://github.com/brettwooldridge/HikariCP/wiki/JDBC-Logging#mysql-connectorj -->
+ <prop key="logger">com.mysql.jdbc.log.StandardLogger</prop>
+ <prop key="logSlowQueries">true</prop>
+ <prop key="dumpQueriesOnException">true</prop>
</props>
- </property>
+ </property>
</bean>
</beans>