Merge branch 'stable-3.2' into stable-3.3 * stable-3.2: Call retryDone() when giving up after lock failures Fix issue with task cleanup after retry Change-Id: I03b5bbfcfca75a3ee54e782e4b64f19b1100e2eb
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 @@ 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 @@ 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 @@ 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 @@ 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();