summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNasser Grainawi <nasser@codeaurora.org>2021-01-29 00:29:14 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-01-29 00:29:14 +0000
commita02e5bde198b618257238f94f73849d7908a469c (patch)
tree26beb08d5054fe77ba7c899f9b1dc2df6ffe5066
parent0e9dae4cc48ecb56ca21ff05cfb22b080f1821fc (diff)
parent10e6268412c94d0fc671d764905e67e5b3ed6f65 (diff)
Merge "Fix cases where replication is waiting indefinitely"
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java2
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java21
2 files changed, 20 insertions, 3 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
index 6117abf..f2b362e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
@@ -591,7 +591,7 @@ public class Destination {
if (inFlightOp != null) {
return RunwayStatus.denied(inFlightOp.getId());
}
- op.setRefs(replicationTasksStorage.get().start(op));
+ op.notifyNotAttempted(op.setStartedRefs(replicationTasksStorage.get().start(op)));
inFlight.put(op.getURI(), op);
}
return RunwayStatus.allowed();
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 ebe169c..404d4bd 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
@@ -52,6 +52,7 @@ import com.googlesource.gerrit.plugins.replication.ReplicationState.RefPushResul
import com.jcraft.jsch.JSchException;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -301,10 +302,26 @@ class PushOne implements ProjectRunnable, CanceledWhileRunning, UriUpdates {
}
}
- void setRefs(Set<String> refs) {
+ Set<String> setStartedRefs(Set<String> startedRefs) {
+ Set<String> notAttemptedRefs = Sets.difference(delta, startedRefs);
pushAllRefs = false;
delta.clear();
- addRefs(refs);
+ addRefs(startedRefs);
+ return notAttemptedRefs;
+ }
+
+ void notifyNotAttempted(Set<String> notAttemptedRefs) {
+ notAttemptedRefs.forEach(
+ ref ->
+ Arrays.asList(getStatesByRef(ref))
+ .forEach(
+ state ->
+ state.notifyRefReplicated(
+ projectName.get(),
+ ref,
+ uri,
+ RefPushResult.NOT_ATTEMPTED,
+ RemoteRefUpdate.Status.UP_TO_DATE)));
}
void addState(String ref, ReplicationState state) {