diff options
author | Nasser Grainawi <nasser@codeaurora.org> | 2021-02-25 12:25:36 -0700 |
---|---|---|
committer | Nasser Grainawi <nasser@codeaurora.org> | 2021-02-25 12:25:36 -0700 |
commit | 2f69b53b8c64b696d6819b4355ea3ac76d8f1293 (patch) | |
tree | 5f62a4faa14cfd5168b5c8907ad422dc1416e080 | |
parent | 9bc78ffa3ac6e96b789b1f83d5e3eabd18311c8b (diff) | |
parent | cc72dc5cb3e4198ebd4f487a3fcc04846e1ceb43 (diff) |
* stable-3.2:
Call retryDone() when giving up after lock failures
Fix issue with task cleanup after retry
Change-Id: I03b5bbfcfca75a3ee54e782e4b64f19b1100e2eb
-rw-r--r-- | src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java | 1 | ||||
-rw-r--r-- | src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationStorageIT.java | 44 |
2 files changed, 23 insertions, 22 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 bdef2fa..ebc8889 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java @@ -414,6 +414,7 @@ class PushOne implements ProjectRunnable, CanceledWhileRunning, UriUpdates { pool.reschedule(this, Destination.RetryReason.TRANSPORT_ERROR); } } else { + retryDone(); repLog.atSevere().log( "Giving up after %d '%s' failures during replication to %s", updateRefRetryCount, e.getMessage(), uri); diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationStorageIT.java b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationStorageIT.java index ff96b1c..01f20b4 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationStorageIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationStorageIT.java @@ -52,8 +52,8 @@ import org.junit.Test; name = "replication", sysModule = "com.googlesource.gerrit.plugins.replication.ReplicationModule") public class ReplicationStorageIT extends ReplicationDaemon { - private static final int TEST_TASK_FINISH_SECONDS = 1; - private static final int TEST_REPLICATION_MAX_RETRIES = 1; + protected static final int TEST_TASK_FINISH_SECONDS = 1; + protected static final int TEST_REPLICATION_MAX_RETRIES = 1; protected static final Duration TEST_TASK_FINISH_TIMEOUT = Duration.ofSeconds(TEST_TASK_FINISH_SECONDS); private static final Duration MAX_RETRY_WITH_TOLERANCE_TIMEOUT = @@ -271,26 +271,6 @@ public class ReplicationStorageIT extends ReplicationDaemon { replicateBranchDeletion(false); } - private void replicateBranchDeletion(boolean mirror) throws Exception { - setReplicationDestination("foo", "replica", ALL_PROJECTS); - reloadConfig(); - - Project.NameKey targetProject = createTestProject(project + "replica"); - String branchToDelete = "refs/heads/todelete"; - String master = "refs/heads/master"; - BranchInput input = new BranchInput(); - input.revision = master; - gApi.projects().name(project.get()).branch(branchToDelete).create(input); - isPushCompleted(targetProject, branchToDelete, TEST_PUSH_TIMEOUT); - - setReplicationDestination("foo", "replica", ALL_PROJECTS, Integer.MAX_VALUE, mirror); - reloadConfig(); - - gApi.projects().name(project.get()).branch(branchToDelete).delete(); - - assertThat(listWaitingReplicationTasks(branchToDelete)).hasSize(1); - } - @Test public void shouldCleanupTasksAfterNewProjectReplication() throws Exception { setReplicationDestination("task_cleanup_project", "replica", ALL_PROJECTS); @@ -353,6 +333,26 @@ public class ReplicationStorageIT extends ReplicationDaemon { WaitUtil.waitUntil(() -> isTaskCleanedUp(), TEST_TASK_FINISH_TIMEOUT); } + private void replicateBranchDeletion(boolean mirror) throws Exception { + setReplicationDestination("foo", "replica", ALL_PROJECTS); + reloadConfig(); + + Project.NameKey targetProject = createTestProject(project + "replica"); + String branchToDelete = "refs/heads/todelete"; + String master = "refs/heads/master"; + BranchInput input = new BranchInput(); + input.revision = master; + gApi.projects().name(project.get()).branch(branchToDelete).create(input); + isPushCompleted(targetProject, branchToDelete, TEST_PUSH_TIMEOUT); + + setReplicationDestination("foo", "replica", ALL_PROJECTS, Integer.MAX_VALUE, mirror); + reloadConfig(); + + gApi.projects().name(project.get()).branch(branchToDelete).delete(); + + assertThat(listWaitingReplicationTasks(branchToDelete)).hasSize(1); + } + private boolean isTaskRescheduled(QueueInfo queue, URIish uri) { PushOne pushOne = queue.pending.get(uri); return pushOne == null ? false : pushOne.isRetrying(); |