diff options
author | Adithya Chakilam <achakila@codeaurora.org> | 2021-01-05 18:44:12 -0600 |
---|---|---|
committer | Adithya Chakilam <achakila@codeaurora.org> | 2021-01-29 00:08:15 +0000 |
commit | 10e6268412c94d0fc671d764905e67e5b3ed6f65 (patch) | |
tree | 54b7db697e4cbb5fcfc0eb218fe44475844ad43b | |
parent | aa2792a5f8a89c21e776cea29082a95d459e0697 (diff) |
Fix cases where replication is waiting indefinitely
In change [1], we started to avoid starting replication tasks which are
not present in ../waiting dir. But the replication commands were waiting
due to state not being updated for the work which is avoided. This
change marks the refs which are neglected as not attempted and in turn
notifies that update to ReplicationState object.
This fix only affects correctness of an internal state.
[1] Ifbb7018ec1d960015626c089a4dadf6b0247d278
Change-Id: Iff31d62ebbbfb88754b43b60344e05dd4b0a1f6d
-rw-r--r-- | src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java | 2 | ||||
-rw-r--r-- | src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java | 21 |
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 12f0273..0b0b58a 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java @@ -583,7 +583,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 565790c..eaed4cf 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; @@ -270,10 +271,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) { |