Retry MergeOp after LOCK_FAILURE when updating branch
If the project requires fast-forwards, the MergeOp cannot succeed once a lock failure occurs, but other cases, it should be safe to retry the merge immediately. So, just put it back in the queue. Change-Id: I9a16e969a9d9c724e4ed20bff030d70eb7bb91d6
This commit is contained in:
@@ -93,6 +93,7 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@@ -131,6 +132,8 @@ public class MergeOp {
|
||||
private static final long DEPENDENCY_DELAY =
|
||||
MILLISECONDS.convert(15, MINUTES);
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
private final GitRepositoryManager repoManager;
|
||||
private final SchemaFactory<ReviewDb> schemaFactory;
|
||||
private final ProjectCache projectCache;
|
||||
@@ -1088,9 +1091,24 @@ public class MergeOp {
|
||||
hooks.doRefUpdatedHook(destBranch, branchUpdate, account);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IOException(branchUpdate.getResult().name());
|
||||
case LOCK_FAILURE:
|
||||
switch (destProject.getSubmitType()) {
|
||||
case CHERRY_PICK:
|
||||
case MERGE_ALWAYS:
|
||||
case MERGE_IF_NECESSARY:
|
||||
mergeQueue.recheckAfter(destBranch, random.nextInt(1000), MILLISECONDS);
|
||||
break;
|
||||
|
||||
case FAST_FORWARD_ONLY:
|
||||
break; // Not mergeable, no need to recheck.
|
||||
default:
|
||||
log.warn("Lock failure in project with unknown merge type "
|
||||
+ destProject.getSubmitType());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
throw new IOException(branchUpdate.getResult().name());
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Cannot update " + branchUpdate.getName(), e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user