Throw lockFailureException when RefDBLock occurs Currently we only retry for lockFailureException, throwing a RefDbLockException will cause the batch to not be retried. Bug: Issue 437621330 Change-Id: Ic2e619ce22b09c991e58a23e4ef5b227f2f6e8dd
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java index 8a4503a..8423d2e 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java +++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java
@@ -27,6 +27,7 @@ import com.google.inject.Inject; import com.google.inject.Singleton; import com.googlesource.gerrit.plugins.multisite.Configuration; +import com.googlesource.gerrit.plugins.replication.pull.FetchOne.LockFailureException; import com.googlesource.gerrit.plugins.replication.pull.ReplicationFetchFilter; import java.io.IOException; import java.util.Collections; @@ -97,7 +98,8 @@ } @Override - public Map<String, AutoCloseable> filterAndLock(String projectName, Set<String> fetchRefs) { + public Map<String, AutoCloseable> filterAndLock(String projectName, Set<String> fetchRefs) + throws LockFailureException { // Use a SortedSet to ensure that they are always locked in the same order and therefore // prevents potential deadlocks where multiple fetch tasks are mutually locking each other // by locking different refs in different orders. @@ -112,7 +114,8 @@ filteredRefs.addAll(filter(projectName, sortedFetchRefs)); } catch (RefDbLockException lockException) { filteredRefs.clear(); - throw lockException; + throw new LockFailureException( + "Unable to lock refs " + sortedFetchRefs + " for project " + projectName, lockException); } finally { for (String excludedRef : Sets.difference(sortedFetchRefs, filteredRefs)) { AutoCloseable excludedLock = refLocks.remove(excludedRef);