Disable the automatic poolSize option

it creates more issues than benefits
This commit is contained in:
Gabriele C 2017-12-13 23:13:28 +01:00
parent 2d77f54695
commit 26a69297ce
6 changed files with 22 additions and 25 deletions

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Tue Nov 28 12:49:57 CET 2017. See docs/config/config.tpl.md -->
<!-- File auto-generated on Wed Dec 13 23:12:29 CET 2017. See docs/config/config.tpl.md -->
## AuthMe Configuration
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
@ -63,8 +63,8 @@ DataSource:
mySQLlastlocYaw: 'yaw'
# Column for storing player LastLocation - Pitch
mySQLlastlocPitch: 'pitch'
# Overrides the size of the DB Connection Pool, -1 = Auto
poolSize: -1
# Overrides the size of the DB Connection Pool, default = 10
poolSize: 10
# The maximum lifetime of a connection in the pool, default = 1800 seconds
# You should set this at least 30 seconds less than mysql server wait_timeout
maxLifetime: 1800
@ -560,4 +560,4 @@ To change settings on a running server, save your changes to config.yml and use
---
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Tue Nov 28 12:49:57 CET 2017
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Wed Dec 13 23:12:29 CET 2017

View File

@ -98,9 +98,6 @@ public class MySQL implements DataSource {
this.col = new Columns(settings);
this.sqlExtension = extensionsFactory.buildExtension(col);
this.poolSize = settings.getProperty(DatabaseSettings.MYSQL_POOL_SIZE);
if (poolSize == -1) {
poolSize = Utils.getCoreCount() * 3;
}
this.maxLifetime = settings.getProperty(DatabaseSettings.MYSQL_CONNECTION_MAX_LIFETIME);
this.useSsl = settings.getProperty(DatabaseSettings.MYSQL_USE_SSL);
}
@ -116,7 +113,6 @@ public class MySQL implements DataSource {
ds.setMaximumPoolSize(poolSize);
ds.setMaxLifetime(maxLifetime * 1000);
// Database URL
ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);

View File

@ -70,6 +70,7 @@ public class SettingsMigrationService extends PlainMigrationService {
| performMailTextToFileMigration(resource)
| migrateJoinLeaveMessages(resource)
| migrateForceSpawnSettings(resource)
| migratePoolSizeSetting(resource)
| changeBooleanSettingToLogLevelProperty(resource)
| hasOldHelpHeaderProperty(resource)
| hasSupportOldPasswordProperty(resource)
@ -194,6 +195,21 @@ public class SettingsMigrationService extends PlainMigrationService {
| moveProperty(oldForceWorlds, FORCE_SPAWN_ON_WORLDS, resource);
}
/**
* Detects the old auto poolSize value and replaces it with the default value.
*
* @param resource The property resource
* @return True if the configuration has changed, false otherwise
*/
private static boolean migratePoolSizeSetting(PropertyResource resource) {
Integer oldValue = resource.getInt("DataSource.poolSize");
if(oldValue == null || oldValue > 0) {
return false;
}
resource.setValue("DataSource.poolSize", 10);
return true;
}
/**
* Changes the old boolean property "hide spam from console" to the new property specifying
* the log level.

View File

@ -123,9 +123,9 @@ public final class DatabaseSettings implements SettingsHolder {
public static final Property<String> MYSQL_COL_GROUP =
newProperty("ExternalBoardOptions.mySQLColumnGroup", "");
@Comment("Overrides the size of the DB Connection Pool, -1 = Auto")
@Comment("Overrides the size of the DB Connection Pool, default = 10")
public static final Property<Integer> MYSQL_POOL_SIZE =
newProperty("DataSource.poolSize", -1);
newProperty("DataSource.poolSize", 10);
@Comment({"The maximum lifetime of a connection in the pool, default = 1800 seconds",
"You should set this at least 30 seconds less than mysql server wait_timeout"})

View File

@ -96,15 +96,6 @@ public final class Utils {
return coll == null || coll.isEmpty();
}
/**
* Return the available core count of the JVM.
*
* @return the core count
*/
public static int getCoreCount() {
return Runtime.getRuntime().availableProcessors();
}
/**
* Returns whether the given email is empty or equal to the standard "undefined" email address.
*

View File

@ -117,12 +117,6 @@ public class UtilsTest {
assertThat(Utils.isCollectionEmpty(null), equalTo(true));
}
@Test
public void shouldReturnCoreCount() {
// given / when / then
assertThat(Utils.getCoreCount(), greaterThan(0));
}
@Test
public void shouldLogAndSendWarning() {
// given