diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java index c19795492..9c70a7d77 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/HikariConnectionFactory.java @@ -37,6 +37,7 @@ import java.sql.Statement; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; +import java.util.concurrent.TimeUnit; public abstract class HikariConnectionFactory implements ConnectionFactory { @@ -77,7 +78,13 @@ public abstract class HikariConnectionFactory implements ConnectionFactory { config.setPoolName("luckperms-hikari"); appendConfigurationInfo(config); - appendProperties(config, new HashMap<>(this.configuration.getProperties())); + + Map properties = new HashMap<>(this.configuration.getProperties()); + + // https://github.com/brettwooldridge/HikariCP/wiki/Rapid-Recovery + properties.putIfAbsent("socketTimeout", String.valueOf(TimeUnit.SECONDS.toMillis(30))); + + appendProperties(config, properties); config.setMaximumPoolSize(this.configuration.getMaxPoolSize()); config.setMinimumIdle(this.configuration.getMinIdleConnections()); diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/MariaDbConnectionFactory.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/MariaDbConnectionFactory.java index 762b33485..2807d364a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/MariaDbConnectionFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/MariaDbConnectionFactory.java @@ -50,10 +50,6 @@ public class MariaDbConnectionFactory extends HikariConnectionFactory { @Override protected void appendProperties(HikariConfig config, Map properties) { - if (properties.isEmpty()) { - return; - } - String propertiesString = properties.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining(";")); // kinda hacky. this will call #setProperties on the datasource, which will append these options diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/MySqlConnectionFactory.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/MySqlConnectionFactory.java index 994694352..5930ba39e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/MySqlConnectionFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/hikari/MySqlConnectionFactory.java @@ -49,15 +49,18 @@ public class MySqlConnectionFactory extends HikariConnectionFactory { @Override protected void appendProperties(HikariConfig config, Map properties) { + // https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration properties.putIfAbsent("cachePrepStmts", "true"); - properties.putIfAbsent("alwaysSendSetIsolation", "false"); - properties.putIfAbsent("cacheServerConfiguration", "true"); - properties.putIfAbsent("elideSetAutoCommits", "true"); - properties.putIfAbsent("useLocalSessionState", "true"); - - properties.putIfAbsent("useServerPrepStmts", "true"); properties.putIfAbsent("prepStmtCacheSize", "250"); properties.putIfAbsent("prepStmtCacheSqlLimit", "2048"); + properties.putIfAbsent("useServerPrepStmts", "true"); + properties.putIfAbsent("useLocalSessionState", "true"); + properties.putIfAbsent("rewriteBatchedStatements", "true"); + properties.putIfAbsent("cacheResultSetMetadata", "true"); + properties.putIfAbsent("cacheServerConfiguration", "true"); + properties.putIfAbsent("elideSetAutoCommits", "true"); + properties.putIfAbsent("maintainTimeStats", "false"); + properties.putIfAbsent("alwaysSendSetIsolation", "false"); properties.putIfAbsent("cacheCallableStmts", "true"); // append configurable properties