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
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 @@
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 @@
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 @@
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;
}
}