summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fick <martin.fick@linaro.org>2022-10-10 06:18:15 -0600
committerMartin Fick <martin.fick@linaro.org>2022-10-10 09:58:11 -0600
commit20f1c213bc2c56bddce03cf8d4b0b63bd609fc20 (patch)
treed0df88230d6006bce635f7ced9667b30e2ec0426
parent4f5de60081d7c098d09c842e3ea9d5bc920df71b (diff)
Demote rename errors when distributor is enabled
Since rename errors for Tasks is common and normal when running with a multi-primary setup, demote them to "atFine()" level when the distributor is enabled. This avoids making the logs extrememly noisy during normal multi-primary operation. Change-Id: I0c90aff769b12f5a1a7506a92f11358c34457cb1
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java
index 4736402..5c7f887 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationTasksStorage.java
@@ -116,9 +116,12 @@ public class ReplicationTasksStorage {
private final Path runningUpdates;
private final Path waitingUpdates;
+ private boolean isMultiPrimary;
+
@Inject
ReplicationTasksStorage(ReplicationConfig config) {
this(config.getEventsDirectory().resolve("ref-updates"));
+ isMultiPrimary = config.getDistributionInterval() != 0;
}
@VisibleForTesting
@@ -130,6 +133,10 @@ public class ReplicationTasksStorage {
new GsonBuilder().registerTypeAdapterFactory(AutoValueTypeAdapterFactory.create()).create();
}
+ private boolean isMultiPrimary() {
+ return isMultiPrimary;
+ }
+
public synchronized String create(ReplicateRefUpdate r) {
return new Task(r).create();
}
@@ -269,7 +276,14 @@ public class ReplicationTasksStorage {
Files.move(from, to, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
return true;
} catch (IOException e) {
- logger.atSevere().withCause(e).log("Error while renaming task %s", taskKey);
+ String message = "Error while renaming task %s";
+ if (isMultiPrimary() && e instanceof NoSuchFileException) {
+ logger.atFine().log(
+ message + " (expected regularly with multi-primaries and distributor enabled)",
+ taskKey);
+ } else {
+ logger.atSevere().withCause(e).log(message, taskKey);
+ }
return false;
}
}