diff options
author | Marcin Czech <maczech@gmail.com> | 2020-05-22 14:10:24 +0200 |
---|---|---|
committer | Luca Milanesio <luca.milanesio@gmail.com> | 2020-05-22 13:25:13 +0000 |
commit | 5316fcbd139760efa87e0bbf95ac110bc6117645 (patch) | |
tree | e23f3fec368820520d17a2cc054fe115d13f5795 | |
parent | b303e1b2963ef5c344ec4bd98e90ff0c80516162 (diff) |
Fix issue with task cleanup after retryv3.1.5
Destination.notifyFinished method calls finish on
ReplicationTasksStorage.Task objects which are not scheduled for retry.
The issue is that for rescheduled tasks PushOne.isRetrying
will always returns true even if task is already replicated.
That creates a situation where tasks scheduled for retry are
never cleaned up.
Bug: Issue 12754
Change-Id: I4b10c2752da6aa7444f57c3ce4ab70eb00c3f14e
-rw-r--r-- | src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java | 5 | ||||
-rw-r--r-- | src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationIT.java | 14 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java index b5838e5..634f44d 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java @@ -218,6 +218,10 @@ class PushOne implements ProjectRunnable, CanceledWhileRunning { return maxRetries == 0 || retryCount <= maxRetries; } + private void retryDone() { + this.retrying = false; + } + void canceledByReplication() { canceled = true; } @@ -348,6 +352,7 @@ class PushOne implements ProjectRunnable, CanceledWhileRunning { metrics.recordSlowProjectReplication( config.getName(), projectName.get(), pool.getSlowLatencyThreshold(), elapsed); } + retryDone(); repLog.info( "Replication to {} completed in {}ms, {}ms delay, {} retries", uri, diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationIT.java b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationIT.java index 19948db..545ae4b 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationIT.java @@ -352,6 +352,20 @@ public class ReplicationIT extends LightweightPluginDaemonTest { } } + @Test + public void shouldCleanupTasksAfterNewProjectReplication() throws Exception { + tasksStorage.disableDeleteForTesting(false); + setReplicationDestination("task_cleanup_project", "replica", ALL_PROJECTS); + config.setInt("remote", "task_cleanup_project", "replicationRetry", 0); + config.save(); + reloadConfig(); + assertThat(tasksStorage.listRunning()).hasSize(0); + Project.NameKey sourceProject = createTestProject("task_cleanup_project"); + + waitUntil(() -> projectExists(Project.nameKey(sourceProject + "replica.git"))); + waitUntil(() -> tasksStorage.listRunning().size() == 0); + } + private Ref getRef(Repository repo, String branchName) throws IOException { return repo.getRefDatabase().exactRef(branchName); } |