documentation: Document database.pool* variables

Also support unit suffixes in the database.poolMaxWait variable,
so it behaves more like cache.maxAge does.

Change-Id: I68afd787cf813344dbbe2c548f1899af77ceabe4
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce 2010-02-23 09:47:10 -08:00
parent 49b9d0ef15
commit 07f35177dc
3 changed files with 50 additions and 1 deletions

View File

@ -624,6 +624,48 @@ database.type or database.url for any supported database.
isn't necessary as it can be constructed from the all of the
above properties.
[[database.poolLimit]]database.poolLimit::
+
Maximum number of open database connections. If the server needs
more than this number, request processing threads will wait up
to <<database.poolMaxWait, poolMaxWait>> seconds for a
connection to be released before they abort with an exception.
This limit must be several units higher than the total number of
httpd and sshd threads as some request processing code paths may
need multiple connections.
+
Default is 8.
[[database.poolMinIdle]]databsae.poolMinIdle::
+
Minimum number of connections to keep idle in the pool.
Default is 4.
[[database.poolMaxIdle]]databsae.poolMaxIdle::
+
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.
[[database.poolMaxWait]]database.poolMaxWait::
+
Maximum amount of time a request processing thread will wait to
acquire a database connection from the pool. If no connection is
released within this time period, the processing thread will abort
its current operations and return an error to the client.
Values should use common unit suffixes to express their setting:
+
* ms, milliseconds
* s, sec, second, seconds
* m, min, minute, minutes
* h, hr, hour, hours
+
If a unit suffix is not specified, `milliseconds` is assumed.
+
Default is `30 seconds`.
[[gerrit]]Section gerrit
~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -156,6 +156,10 @@ public class ConfigUtil {
inputUnit = wantUnit;
inputMul = 1;
} else if (match(unitName, "ms", "milliseconds")) {
inputUnit = TimeUnit.MILLISECONDS;
inputMul = 1;
} else if (match(unitName, "s", "sec", "second", "seconds")) {
inputUnit = TimeUnit.SECONDS;
inputMul = 1;

View File

@ -15,8 +15,10 @@
package com.google.gerrit.server.schema;
import static com.google.gerrit.server.config.ConfigUtil.getEnum;
import static java.util.concurrent.TimeUnit.*;
import com.google.gerrit.lifecycle.LifecycleListener;
import com.google.gerrit.server.config.ConfigUtil;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.SitePaths;
import com.google.gwtorm.jdbc.SimpleDataSource;
@ -184,7 +186,8 @@ public final class DataSourceProvider implements Provider<DataSource>,
ds.setMaxActive(cfg.getInt("database", "poollimit", 8));
ds.setMinIdle(cfg.getInt("database", "poolminidle", 4));
ds.setMaxIdle(cfg.getInt("database", "poolmaxidle", 4));
ds.setMaxWait(cfg.getInt("database", "poolmaxwait", 30000));
ds.setMaxWait(ConfigUtil.getTimeUnit(cfg, "database", null,
"poolmaxwait", MILLISECONDS.convert(30, SECONDS), MILLISECONDS));
ds.setInitialSize(ds.getMinIdle());
return ds;