summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fick <mfick@codeaurora.org>2020-05-08 11:28:54 -0600
committerNasser Grainawi <nasser@codeaurora.org>2020-05-08 23:07:43 +0000
commitef028220da5c9fc185b840e35d43e86bf7adb380 (patch)
treeecfd88ca1afb6d53f11b8f25e1ebca244481fc2e
parentb7a86cdca9eac3c0cb4292202c04788bf000ea51 (diff)
Fix start --wait to track in-flight collisions and to not fail
Previously when an in-flight collision occurred on a push that the 'start --wait' command was waiting for, the command would terminate with an error (and if it weren't for an NPE it would stop waiting prematurely). This was happening because PushOne is not tracking collisions resulting in its cleanup code assuming there was a failure. Fix this by tracking the collision in PushOne and skipping the cleanup in this case. Ironically, the NPE in change I107d964a33349aaa5d6ae9aca68aab2889689155 was preventing the start command from receiving the premature termination on the collision, but it was not preventing the error. Thus this fix should get merged before fixing the NPE to avoid a worse scenario. Change-Id: Ibf1ca624739205f6f92e097213828faf29de9300 Bug: Issue 12719
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java5
1 files changed, 4 insertions, 1 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 966d7c0..8ccd54a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/PushOne.java
@@ -102,6 +102,7 @@ class PushOne implements ProjectRunnable, CanceledWhileRunning {
private final Set<String> delta = Sets.newHashSetWithExpectedSize(4);
private boolean pushAllRefs;
private Repository git;
+ private boolean isCollision;
private boolean retrying;
private int retryCount;
private final int maxRetries;
@@ -277,7 +278,7 @@ class PushOne implements ProjectRunnable, CanceledWhileRunning {
}
private void statesCleanUp() {
- if (!stateMap.isEmpty() && !isRetrying()) {
+ if (!stateMap.isEmpty() && !isRetrying() && !isCollision) {
for (Map.Entry<String, ReplicationState> entry : stateMap.entries()) {
entry
.getValue()
@@ -315,6 +316,7 @@ class PushOne implements ProjectRunnable, CanceledWhileRunning {
//
MDC.put(ID_MDC_KEY, HexFormat.fromInt(id));
RunwayStatus status = pool.requestRunway(this);
+ isCollision = false;
if (!status.isAllowed()) {
if (status.isCanceled()) {
repLog.info("PushOp for replication to {} was canceled and thus won't be rescheduled", uri);
@@ -324,6 +326,7 @@ class PushOne implements ProjectRunnable, CanceledWhileRunning {
uri,
HexFormat.fromInt(status.getInFlightPushId()));
pool.reschedule(this, Destination.RetryReason.COLLISION);
+ isCollision = true;
}
return;
}