Ignore refs/multi-site/version on global-refdb in push replication filter When I509dd7075b0 stopped updating the SHA1 for refs/multi-site/version in global-refdb in this stable-3.4 branch, it did not take into consideration that existing setups may have plenty of refs/multi-site/version already stored on them. Stopping the update of those refs on the global-refdb had a negative impact on the consistency of the replication of refs/multi-site/version across the multi-site clusters, causing missed replication events. Consider the refs/multi-site/version on global-refdb as non-existent and skip altogether the associated checks if the associated local refs were already up-to-date. This change effectively ignores weather the local refs/multi-site/version is up-to-date or not and always pushes the refs to replication remotes. This is the completion of the similar fix performed on the MultisiteReplicationFetchFilter in I8b938675. Change-Id: I833138849807475a7aed308d8703bb7e16728d2d
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationPushFilter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationPushFilter.java index 6f9c2e7..777886d 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationPushFilter.java +++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationPushFilter.java
@@ -14,6 +14,8 @@ package com.googlesource.gerrit.plugins.multisite.validation; +import static com.googlesource.gerrit.plugins.multisite.validation.ProjectVersionRefUpdate.MULTI_SITE_VERSIONING_REF; + import com.gerritforge.gerrit.globalrefdb.GlobalRefDbLockException; import com.gerritforge.gerrit.globalrefdb.validation.SharedRefDatabaseWrapper; import com.google.common.base.Preconditions; @@ -111,6 +113,10 @@ private Optional<RemoteRefUpdate> isUpToDateWithRetry( String projectName, Repository repository, RemoteRefUpdate refUpdate) { + if (shouldNotBeTrackedAnymoreOnGlobalRefDb(refUpdate.getSrcRef())) { + return Optional.of(refUpdate); + } + String ref = refUpdate.getSrcRef(); try { if (sharedRefDb.isUpToDate( @@ -146,6 +152,19 @@ } } + /* + * Since ac43a5f94c773c9db7a73d44035961d69d13fa53 the 'refs/multi-site/version' is + * not updated anymore on the global-refdb; however, the values stored already + * on the global-refdb could get in the way and prevent replication from happening + * as expected. + * + * Exclude the 'refs/multi-site/version' from local vs. global refdb checking + * pretending that the global-refdb for that ref did not exist. + */ + private boolean shouldNotBeTrackedAnymoreOnGlobalRefDb(String ref) { + return MULTI_SITE_VERSIONING_REF.equals(ref); + } + private RemoteRefUpdate newRemoteRefUpdateWithObjectId( Repository localDb, RemoteRefUpdate refUpdate, ObjectId reloadedNewObjectId) throws IOException {