Merge branch 'stable-3.1' into stable-3.2 * stable-3.1: Call retryDone() when giving up after lock failures Fix issue with task cleanup after retry Change-Id: I6dbeaa0d21545a1903bdb11c5de5d9e8f72079c5
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 dd584ce..31a4f49 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationStorageIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replication/ReplicationStorageIT.java
@@ -51,8 +51,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 = @@ -270,26 +270,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); @@ -352,6 +332,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();