Do not accumulate replication events with retrying tasks When a replication tasks is retrying is always discovered in the search for pending tasks for a source URI. Adding more work to a replication tasks that failed and is potentially struggling is a bad idea. 1. If a replication task failed it means that there are temporary or persistent issues in completing the task. Adding more refs to the same failing replication task would put those refs into a future execution that may never succeed. 2. If the replication tasks was just too heavy and struggled to pass because of timeouts or bandwidth issues, adding yet another ref to fetch would put more burden to it and making the retries more likely to fail. Avoiding to group with a retrying replication task may add more latency because of the extra operation; however, it would give more chances to succeed. Bug: Issue 16789 Change-Id: Ifbe2939be69ad4e5d89e8a49402e9949a0956473
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java index 0162ad0..45ab7e2 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java
@@ -441,7 +441,7 @@ synchronized (stateLock) { FetchOne e = pending.get(uri); Future<?> f = CompletableFuture.completedFuture(null); - if (e == null) { + if (e == null || e.isRetrying()) { e = opFactory.create(project, uri, apiRequestMetrics); addRef(e, ref); e.addState(ref, state);