summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntonio Barone <syntonyze@gmail.com>2023-11-17 12:11:54 -0800
committerAntonio Barone <syntonyze@gmail.com>2023-11-19 16:37:44 +0000
commitaf810186ca5d50b4295eb16959a8f2a59df3607f (patch)
treee1040447fcb14e07e62550ba57d08e7f2e5a0ee2
parent63c798db62c3994a6609ba089c889a83fb33e35f (diff)
NoteDBMigrator: allow to disable executor metrics
By default the WorkQueue executor used to run the online noteDb migration is created with metrics-capability, so that the scheduling the execution and the termination of submitted tasks could be monitored. Upon termination of the ThreadPool executor, however, the metrics are not removed from the metrics registry. This is not just polluting the metrics registry with unnecessary metrics, but it is also preventing from creating another queue with the same name later within the same Gerrit runtime, causing the following exception: java.lang.IllegalArgumentException: A metric named queue/<queue_name>/max_pool_size already exists The root cause of this problem could be fixed by cherry-picking I06d48535702a and explicitly de-register the metrics upon executor termination, as attempted in Iaca9881cd46. Unfortunately however, this cannot be done on stable-2.16, because it would break binary-compatibility on all existing plugins that are using metrics. Allow to explicitly disable the NoteDBMigrator WorkQueue metrics ("RebuildChange"), so that subsequent online migrations can be triggered without causing metrics collision. Note that this is not a problem for the `migrate-to-notedb` program, which is using `DisabledMetriMaker`, hence not emitting metrics at all. Release-Notes: skip Forward-Compatible: checked Change-Id: Iaca9881cd467e32829d630aa0c259a8880e08c86
-rw-r--r--java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java b/java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java
index ec27ba27f8..ea8b9f5259 100644
--- a/java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java
+++ b/java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java
@@ -208,6 +208,7 @@ public class NoteDbMigrator implements AutoCloseable {
private boolean autoMigrate;
private boolean lockLooseRefs;
private boolean verbose;
+ private boolean executorMetrics = true;
@Inject
Builder(
@@ -480,6 +481,17 @@ public class NoteDbMigrator implements AutoCloseable {
return this;
}
+ /**
+ * Set whether to enable the executor metrics.
+ *
+ * @param executorMetrics whether to enable the executor metrics (default true)
+ * @return this
+ */
+ public Builder setEnableExecutorMetrics(boolean executorMetrics) {
+ this.executorMetrics = executorMetrics;
+ return this;
+ }
+
public NoteDbMigrator build() throws MigrationException {
return new NoteDbMigrator(
sitePaths,
@@ -498,7 +510,7 @@ public class NoteDbMigrator implements AutoCloseable {
listeners,
threads > 1
? MoreExecutors.listeningDecorator(
- workQueue.createQueue(threads, "RebuildChange", true))
+ workQueue.createQueue(threads, "RebuildChange", executorMetrics))
: MoreExecutors.newDirectExecutorService(),
projects,
skipProjects,