diff --git a/bukkit/src/main/resources/config.yml b/bukkit/src/main/resources/config.yml index ffa5ef2a3..1679d232f 100644 --- a/bukkit/src/main/resources/config.yml +++ b/bukkit/src/main/resources/config.yml @@ -128,6 +128,12 @@ data: # connection time limit. maximum-lifetime: 1800000 # 30 minutes + # This setting controls how frequently the pool will 'ping' a connection in order to prevent it + # from being timed out by the database or network infrastructure, measured in milliseconds. + # - The value should be less than maximum-lifetime and greater than 30000 (30 seconds). + # - Setting the value to zero will disable the keepalive functionality. + keepalive-time: 0 + # This setting controls the maximum number of milliseconds that the plugin will wait for a # connection from the pool, before timing out. connection-timeout: 5000 # 5 seconds diff --git a/bungee/src/main/resources/config.yml b/bungee/src/main/resources/config.yml index 17ffcf296..b230e57ed 100644 --- a/bungee/src/main/resources/config.yml +++ b/bungee/src/main/resources/config.yml @@ -125,6 +125,12 @@ data: # connection time limit. maximum-lifetime: 1800000 # 30 minutes + # This setting controls how frequently the pool will 'ping' a connection in order to prevent it + # from being timed out by the database or network infrastructure, measured in milliseconds. + # - The value should be less than maximum-lifetime and greater than 30000 (30 seconds). + # - Setting the value to zero will disable the keepalive functionality. + keepalive-time: 0 + # This setting controls the maximum number of milliseconds that the plugin will wait for a # connection from the pool, before timing out. connection-timeout: 5000 # 5 seconds diff --git a/common/build.gradle b/common/build.gradle index ba5d577f3..c9682db7b 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -51,7 +51,7 @@ dependencies { compile('me.lucko.configurate:configurate-toml:3.7') { exclude(module: 'toml4j') } - compile 'com.zaxxer:HikariCP:3.4.5' + compile 'com.zaxxer:HikariCP:4.0.2' compile 'redis.clients:jedis:3.3.0' compile 'com.rabbitmq:amqp-client:5.10.0' compile 'org.mongodb:mongo-java-driver:3.12.2' diff --git a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java index 26577b759..7c9eecd72 100644 --- a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java +++ b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java @@ -516,6 +516,7 @@ public final class ConfigKeys { int maxPoolSize = c.getInteger("data.pool-settings.maximum-pool-size", c.getInteger("data.pool-size", 10)); int minIdle = c.getInteger("data.pool-settings.minimum-idle", maxPoolSize); int maxLifetime = c.getInteger("data.pool-settings.maximum-lifetime", 1800000); + int keepAliveTime = c.getInteger("data.pool-settings.keepalive-time", 0); int connectionTimeout = c.getInteger("data.pool-settings.connection-timeout", 5000); Map props = ImmutableMap.copyOf(c.getStringMap("data.pool-settings.properties", ImmutableMap.of())); @@ -524,7 +525,7 @@ public final class ConfigKeys { c.getString("data.database", null), c.getString("data.username", null), c.getString("data.password", null), - maxPoolSize, minIdle, maxLifetime, connectionTimeout, props + maxPoolSize, minIdle, maxLifetime, keepAliveTime, connectionTimeout, props ); })); 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 4a9a73f66..21c560d69 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 @@ -146,6 +146,7 @@ public abstract class HikariConnectionFactory implements ConnectionFactory { config.setMaximumPoolSize(this.configuration.getMaxPoolSize()); config.setMinimumIdle(this.configuration.getMinIdleConnections()); config.setMaxLifetime(this.configuration.getMaxLifetime()); + config.setKeepaliveTime(this.configuration.getKeepAliveTime()); config.setConnectionTimeout(this.configuration.getConnectionTimeout()); // don't perform any initial connection validation - we subsequently call #getConnection diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/misc/StorageCredentials.java b/common/src/main/java/me/lucko/luckperms/common/storage/misc/StorageCredentials.java index 8ec73eb26..731d0d4f6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/misc/StorageCredentials.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/misc/StorageCredentials.java @@ -37,10 +37,11 @@ public class StorageCredentials { private final int maxPoolSize; private final int minIdleConnections; private final int maxLifetime; + private final int keepAliveTime; private final int connectionTimeout; private final Map properties; - public StorageCredentials(String address, String database, String username, String password, int maxPoolSize, int minIdleConnections, int maxLifetime, int connectionTimeout, Map properties) { + public StorageCredentials(String address, String database, String username, String password, int maxPoolSize, int minIdleConnections, int maxLifetime, int keepAliveTime, int connectionTimeout, Map properties) { this.address = address; this.database = database; this.username = username; @@ -48,6 +49,7 @@ public class StorageCredentials { this.maxPoolSize = maxPoolSize; this.minIdleConnections = minIdleConnections; this.maxLifetime = maxLifetime; + this.keepAliveTime = keepAliveTime; this.connectionTimeout = connectionTimeout; this.properties = properties; } @@ -80,6 +82,10 @@ public class StorageCredentials { return this.maxLifetime; } + public int getKeepAliveTime() { + return this.keepAliveTime; + } + public int getConnectionTimeout() { return this.connectionTimeout; } diff --git a/fabric/src/main/resources/luckperms.conf b/fabric/src/main/resources/luckperms.conf index b36eca836..547626e4c 100644 --- a/fabric/src/main/resources/luckperms.conf +++ b/fabric/src/main/resources/luckperms.conf @@ -128,6 +128,12 @@ data { # connection time limit. maximum-lifetime = 1800000 # 30 minutes + # This setting controls how frequently the pool will 'ping' a connection in order to prevent it + # from being timed out by the database or network infrastructure, measured in milliseconds. + # - The value should be less than maximum-lifetime and greater than 30000 (30 seconds). + # - Setting the value to zero will disable the keepalive functionality. + keepalive-time = 0 + # This setting controls the maximum number of milliseconds that the plugin will wait for a # connection from the pool, before timing out. connection-timeout = 5000 # 5 seconds diff --git a/nukkit/src/main/resources/config.yml b/nukkit/src/main/resources/config.yml index d7d4da3c8..f799abe38 100644 --- a/nukkit/src/main/resources/config.yml +++ b/nukkit/src/main/resources/config.yml @@ -128,6 +128,12 @@ data: # connection time limit. maximum-lifetime: 1800000 # 30 minutes + # This setting controls how frequently the pool will 'ping' a connection in order to prevent it + # from being timed out by the database or network infrastructure, measured in milliseconds. + # - The value should be less than maximum-lifetime and greater than 30000 (30 seconds). + # - Setting the value to zero will disable the keepalive functionality. + keepalive-time: 0 + # This setting controls the maximum number of milliseconds that the plugin will wait for a # connection from the pool, before timing out. connection-timeout: 5000 # 5 seconds diff --git a/sponge/src/main/resources/luckperms.conf b/sponge/src/main/resources/luckperms.conf index 10bbefb04..e414d2212 100644 --- a/sponge/src/main/resources/luckperms.conf +++ b/sponge/src/main/resources/luckperms.conf @@ -128,6 +128,12 @@ data { # connection time limit. maximum-lifetime = 1800000 # 30 minutes + # This setting controls how frequently the pool will 'ping' a connection in order to prevent it + # from being timed out by the database or network infrastructure, measured in milliseconds. + # - The value should be less than maximum-lifetime and greater than 30000 (30 seconds). + # - Setting the value to zero will disable the keepalive functionality. + keepalive-time = 0 + # This setting controls the maximum number of milliseconds that the plugin will wait for a # connection from the pool, before timing out. connection-timeout = 5000 # 5 seconds diff --git a/velocity/src/main/resources/config.yml b/velocity/src/main/resources/config.yml index 234fe2a6d..d41573f88 100644 --- a/velocity/src/main/resources/config.yml +++ b/velocity/src/main/resources/config.yml @@ -118,6 +118,12 @@ data: # connection time limit. maximum-lifetime: 1800000 # 30 minutes + # This setting controls how frequently the pool will 'ping' a connection in order to prevent it + # from being timed out by the database or network infrastructure, measured in milliseconds. + # - The value should be less than maximum-lifetime and greater than 30000 (30 seconds). + # - Setting the value to zero will disable the keepalive functionality. + keepalive-time: 0 + # This setting controls the maximum number of milliseconds that the plugin will wait for a # connection from the pool, before timing out. connection-timeout: 5000 # 5 seconds