Change default value of database.poolMaxIdle

Set database.poolMaxIdle default value to minimum of database.poolIdle
and 16. This way Gerrit keeps more active connections to database making
in more responsive (since db connections are not initialized every
time).

Change-Id: If00796eb7ccd2cf88773a7f41a0e9eb1da875fe2
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
This commit is contained in:
Dariusz Luksza
2015-11-09 22:19:59 +01:00
parent 4b5a416b49
commit 30d70aef09
2 changed files with 5 additions and 3 deletions

View File

@@ -1423,7 +1423,7 @@ This setting only applies if
Maximum number of connections to keep idle in the pool. If there
are more idle connections, connections will be closed instead of
being returned back to the pool.
Default is 4.
Default is min(<<database.poolLimit, database.poolLimit>>, 16).
+
This setting only applies if
<<database.connectionPool,database.connectionPool>> is true.

View File

@@ -129,9 +129,11 @@ public class DataSourceProvider implements Provider<DataSource>,
if (password != null && !password.isEmpty()) {
ds.setPassword(password);
}
ds.setMaxActive(threadSettingsConfig.getDatabasePoolLimit());
int poolLimit = threadSettingsConfig.getDatabasePoolLimit();
ds.setMaxActive(poolLimit);
ds.setMinIdle(cfg.getInt("database", "poolminidle", 4));
ds.setMaxIdle(cfg.getInt("database", "poolmaxidle", 4));
ds.setMaxIdle(
cfg.getInt("database", "poolmaxidle", Math.min(poolLimit, 16)));
ds.setMaxWait(ConfigUtil.getTimeUnit(cfg, "database", null,
"poolmaxwait", MILLISECONDS.convert(30, SECONDS), MILLISECONDS));
ds.setInitialSize(ds.getMinIdle());