summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Milanesio <luca.milanesio@gmail.com>2023-09-14 20:18:58 +0100
committerLuca Milanesio <luca.milanesio@gmail.com>2023-09-14 19:24:22 +0000
commit2ec4e1c0b7c8c74b21558503cd5e2a72a6a5b118 (patch)
treee50c65fb5bdc96d92797a5a7e8191a7cbb5079a0
parent4f126715f846b5c7e8c4150dfed9db3a8eb68c51 (diff)
parentfe75aa71aa0f1525ce4d58003c45ba29dd22e6ac (diff)
Merge branch 'stable-3.7' into stable-3.8
* stable-3.7: Set version to 3.7.6-SNAPSHOT Set version to 3.7.5 Set version to 3.6.8-SNAPSHOT Set version to 3.6.7 Update Eclipse dev guide Support Cloud Spanner for AccountPatchReviewStore Remove warning on persisted_projects cache on multi-servers setups Documentation: NOTE on use of sshkeys, and *projects cache on clusters Align Jetty session timeout with Gerrit web_sessions maxAge Release-Notes: skip Change-Id: I953df426784abc5898461d54bc1b7ea07d3f6dec
-rw-r--r--Documentation/config-gerrit.txt16
-rw-r--r--Documentation/dev-eclipse.txt4
-rw-r--r--java/com/google/gerrit/pgm/http/jetty/JettyServer.java11
-rw-r--r--java/com/google/gerrit/server/schema/CloudSpannerAccountPatchReviewStore.java67
-rw-r--r--java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java14
5 files changed, 107 insertions, 5 deletions
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index 6b8f10a3db..edd2b7c808 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -37,9 +37,10 @@ flags.
[[accountPatchReviewDb.url]]accountPatchReviewDb.url::
+
-The url of accountPatchReviewDb. Supported types are `H2`, `POSTGRESQL`,
-`MARIADB`, and `MYSQL`. Drop the driver jar in the lib folder of the site path
-if the Jdbc driver of the corresponding Database is not yet in the class path.
+The url of accountPatchReviewDb. Supported types are `CLOUDSPANNER`, `H2`,
+`POSTGRESQL`, `MARIADB`, and `MYSQL`. Drop the driver jar in the lib folder of
+the site path if the Jdbc driver of the corresponding Database is not yet in
+the class path.
+
Default is to create H2 database in the db folder of the site path.
+
@@ -1205,6 +1206,9 @@ branch of each project. If a project record is updated or deleted, this
cache should be flushed. Newly inserted projects do not require
a cache flush, as they will be read upon first reference.
+NOTE: This cache should be disabled or set with a low refreshAfterWrite
+in a cluster setup using multiple primary or multiple replica nodes.
+
cache `"prolog_rules"`::
+
Caches parsed `rules.pl` contents for each project. This cache uses the same
@@ -1231,6 +1235,9 @@ is per-user, so 1024 items translates to 1024 unique user accounts.
As each individual user account may configure multiple SSH keys,
the total number of keys may be larger than the item count.
+NOTE: This cache should be disabled or set with a low refreshAfterWrite
+in a cluster setup using multiple primary or multiple replica nodes.
+
cache `"web_sessions"`::
+
Tracks the live user sessions coming in over HTTP. Flushing this
@@ -1247,6 +1254,9 @@ is strongly recommended.
+
Session storage is relatively inexpensive. The average entry in
this cache is approximately 346 bytes.
++
+The `maxAge` configuration is also used for as maximum lifetime
+of the HTTP servlet container session.
See also link:cmd-flush-caches.html[gerrit flush-caches].
diff --git a/Documentation/dev-eclipse.txt b/Documentation/dev-eclipse.txt
index 735309239d..a76282efc9 100644
--- a/Documentation/dev-eclipse.txt
+++ b/Documentation/dev-eclipse.txt
@@ -82,6 +82,10 @@ the same way you would when
link:dev-build-plugins.html#_bundle_custom_plugin_in_release_war[bundling in release.war]
and run `tools/eclipse/project.py`.
+If a plugin requires additional test dependencies (not available in the Gerrit), then in order to
+execute tests directly from Eclipse, that plugin must be also added to `CUSTOM_PLUGINS_TEST_DEPS`
+list in `tools/bzl/plugins.bzl` (note that `tools/eclipse/project.py` has to be run again).
+
== Java Versions
Java 11 is supported as a default, but some adjustments must be done for other JDKs:
diff --git a/java/com/google/gerrit/pgm/http/jetty/JettyServer.java b/java/com/google/gerrit/pgm/http/jetty/JettyServer.java
index 6f3514f974..10fe2f374c 100644
--- a/java/com/google/gerrit/pgm/http/jetty/JettyServer.java
+++ b/java/com/google/gerrit/pgm/http/jetty/JettyServer.java
@@ -14,7 +14,9 @@
package com.google.gerrit.pgm.http.jetty;
+import static com.google.gerrit.httpd.CacheBasedWebSession.MAX_AGE_MINUTES;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
import com.google.common.annotations.VisibleForTesting;
@@ -244,6 +246,15 @@ public class JettyServer {
}
});
+ sessionHandler.setMaxInactiveInterval(
+ (int)
+ cfg.getTimeUnit(
+ "cache",
+ "web_sessions",
+ "maxAge",
+ SECONDS.convert(MAX_AGE_MINUTES, MINUTES),
+ SECONDS));
+
Handler app = makeContext(env, cfg, sessionHandler);
if (cfg.getBoolean("httpd", "requestLog", !reverseProxy)) {
RequestLogHandler handler = new RequestLogHandler();
diff --git a/java/com/google/gerrit/server/schema/CloudSpannerAccountPatchReviewStore.java b/java/com/google/gerrit/server/schema/CloudSpannerAccountPatchReviewStore.java
new file mode 100644
index 0000000000..3c88e3ab9d
--- /dev/null
+++ b/java/com/google/gerrit/server/schema/CloudSpannerAccountPatchReviewStore.java
@@ -0,0 +1,67 @@
+// Copyright (C) 2023 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.schema;
+
+import com.google.gerrit.exceptions.DuplicateKeyException;
+import com.google.gerrit.exceptions.StorageException;
+import com.google.gerrit.server.config.GerritServerConfig;
+import com.google.gerrit.server.config.SitePaths;
+import com.google.gerrit.server.config.ThreadSettingsConfig;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.sql.SQLException;
+import java.sql.Statement;
+import org.eclipse.jgit.lib.Config;
+
+@Singleton
+public class CloudSpannerAccountPatchReviewStore extends JdbcAccountPatchReviewStore {
+
+ private static final int ERR_DUP_KEY = 1022;
+ private static final int ERR_DUP_ENTRY = 1062;
+ private static final int ERR_DUP_UNIQUE = 1169;
+
+ @Inject
+ CloudSpannerAccountPatchReviewStore(
+ @GerritServerConfig Config cfg,
+ SitePaths sitePaths,
+ ThreadSettingsConfig threadSettingsConfig) {
+ super(cfg, sitePaths, threadSettingsConfig);
+ }
+
+ @Override
+ public StorageException convertError(String op, SQLException err) {
+ switch (err.getErrorCode()) {
+ case ERR_DUP_KEY:
+ case ERR_DUP_ENTRY:
+ case ERR_DUP_UNIQUE:
+ return new DuplicateKeyException("ACCOUNT_PATCH_REVIEWS", err);
+
+ default:
+ convertError(op, err);
+ return new StorageException(op + " failure on ACCOUNT_PATCH_REVIEWS", err);
+ }
+ }
+
+ @Override
+ protected void doCreateTable(Statement stmt) throws SQLException {
+ stmt.executeUpdate(
+ "CREATE TABLE IF NOT EXISTS account_patch_reviews ("
+ + "account_id INT64 NOT NULL DEFAULT (0),"
+ + "change_id INT64 NOT NULL DEFAULT (0),"
+ + "patch_set_id INT64 NOT NULL DEFAULT (0),"
+ + "file_name STRING(MAX) NOT NULL DEFAULT ('')"
+ + ") PRIMARY KEY(change_id, patch_set_id, account_id, file_name)");
+ }
+}
diff --git a/java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java b/java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java
index 189d448d2b..8cc140edd9 100644
--- a/java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java
+++ b/java/com/google/gerrit/server/schema/JdbcAccountPatchReviewStore.java
@@ -53,8 +53,9 @@ public abstract class JdbcAccountPatchReviewStore
implements AccountPatchReviewStore, LifecycleListener {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
- // DB_CLOSE_DELAY=-1: By default the content of an in-memory H2 database is lost at the moment the
- // last connection is closed. This option keeps the content as long as the VM lives.
+ // DB_CLOSE_DELAY=-1: By default the content of an in-memory H2 database is lost
+ // at the moment the last connection is closed. This option keeps the content as
+ // long as the VM lives.
@VisibleForTesting
public static final String TEST_IN_MEMORY_URL =
"jdbc:h2:mem:account_patch_reviews;DB_CLOSE_DELAY=-1";
@@ -64,6 +65,7 @@ public abstract class JdbcAccountPatchReviewStore
private static final String MARIADB = "mariadb";
private static final String MYSQL = "mysql";
private static final String POSTGRESQL = "postgresql";
+ private static final String CLOUDSPANNER = "cloudspanner";
private static final String URL = "url";
public static class JdbcAccountPatchReviewStoreModule extends LifecycleModule {
@@ -85,6 +87,8 @@ public abstract class JdbcAccountPatchReviewStore
impl = MysqlAccountPatchReviewStore.class;
} else if (url.contains(MARIADB)) {
impl = MariaDBAccountPatchReviewStore.class;
+ } else if (url.contains(CLOUDSPANNER)) {
+ impl = CloudSpannerAccountPatchReviewStore.class;
} else {
throw new IllegalArgumentException(
"unsupported driver type for account patch reviews db: " + url);
@@ -111,6 +115,9 @@ public abstract class JdbcAccountPatchReviewStore
if (url.contains(MARIADB)) {
return new MariaDBAccountPatchReviewStore(cfg, sitePaths, threadSettingsConfig);
}
+ if (url.contains(CLOUDSPANNER)) {
+ return new CloudSpannerAccountPatchReviewStore(cfg, sitePaths, threadSettingsConfig);
+ }
throw new IllegalArgumentException(
"unsupported driver type for account patch reviews db: " + url);
}
@@ -164,6 +171,9 @@ public abstract class JdbcAccountPatchReviewStore
if (url.contains(MARIADB)) {
return "org.mariadb.jdbc.Driver";
}
+ if (url.contains(CLOUDSPANNER)) {
+ return "com.google.cloud.spanner.jdbc.JdbcDriver";
+ }
return "org.h2.Driver";
}