commit | 19c94bce1139cb014837c7a06917b4b940505689 | [log] [tgz] |
---|---|---|
author | Jacek Centkowski <jcentkowski@collab.net> | Mon Apr 16 14:58:58 2018 +0200 |
committer | Jacek Centkowski <jcentkowski@collab.net> | Tue Apr 24 10:37:21 2018 +0200 |
tree | 5792c18ce8bf3fe44f3f510d783a8aa4c6623787 | |
parent | 8bb9b1dcf341c155741dfe53ed6dc7b6e6b73d4b [diff] |
Introduce lib that contains Postgres based persistent cache impl The following change introduces cache-postgres.jar library that contains Postgres based persistence implementation for Gerrit caches. It is heavily based on existing Gerrit's H2CacheImpl and could/should be further optimized in the follow up changes. One builds it by calling: bazel build cache-postgres Installation: 1. create Postgres DB e.g. gerrit_caches 2. copy 'bazel-genfiles/cache-postgres.jar' to GERRIT_SITE/lib dir 3. modify GERRIT_SITE/etc/gerrit.config with the following changes a) inform Gerrit that main library's module should be loaded gerrit.installModule "com.googlesource.gerrit.modules.cache.pg.CacheModule" b) specify connection to Postgres DB cache.url "jdbc:postgresql://localhost:5432/gerrit_caches?user=gerrit&password=gerrit" 4. restart Gerrit 5. remaining configuration parameters are mentioned in README.md NOTES: 1. current implementation doesn't contain migration step and existing data will be wiped out. 2. it uses INSERT INTO ... ON CONFLICT DO UPDATE ... upsert syntax [1] therefore it is Postgres 9.5+ compatible. [1] https://stackoverflow.com/questions/17267417/how-to-upsert-merge-insert-on-duplicate-update-in-postgresql Depends-On: I7562b210fad4c5f6dc67887f627cf76815a378cb Change-Id: I33fa1cd3dba1c1b246aecaa05a052f7348ddd64a Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
Gerrit lib module to swap existing persistent cache implementation (that is H2 based) with implementation that stores data in Postgres. Note that is uses INSERT INTO ... ON CONFLICT DO UPDATE ... upsert syntax therefore it is Postgres 9.5+ compatible.
Build this module similarly to standalone build for any other, bazel based Gerrit plugin:
bazel build cache-postgres
cache-postgres.jar
module is generated under /bazel-genfiles/cache-postgres.jar
Copy cache-postgres.jar
library to Gerrit /lib
and add the following two extra settings to gerrit.config
:
[gerrit] installModule = com.googlesource.gerrit.modules.cache.pg.CacheModule [cache] url = jdbc:postgresql://localhost:5432/gerrit_caches?user=gerrit&password=gerrit
cache
cache.url : URI that specifies connection to existing DB (including both username and passwword).
cache.poolLimit : Maximum number of open database connections. If the server needs more than this number, request processing threads will wait up to cache.poolMaxWait
seconds for a connection to be released before they abort with an exception. Default value is taken from database.poolLimit
.
cache.poolMinIdle : Minimum number of connections to keep idle in the pool. Default is 4
.
cache.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 min(cache.poolLimit
, 16
).
cache.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:
If a unit suffix is not specified, milliseconds
is assumed. Default is 30 seconds
.