Merge "Move message logging to events-broker"
diff --git a/.gitignore b/.gitignore
index 8bccbdb..c2375ae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,6 @@
/eclipse-out/
setup_local_env/**/*.env
+
+.idea
+*.iml
diff --git a/setup_local_env/configs/gerrit.config b/setup_local_env/configs/gerrit.config
index 8a176f2..c92c60d 100644
--- a/setup_local_env/configs/gerrit.config
+++ b/setup_local_env/configs/gerrit.config
@@ -1,3 +1,5 @@
+[core]
+ usePerRequestRefCache = false
[gerrit]
basePath = git
serverId = 69ec38f0-350e-4d9c-96d4-bc956f2faaac
@@ -39,8 +41,6 @@
directory = cache
[plugins]
allowRemoteAdmin = true
-[plugin "websession-flatfile"]
- directory = $FAKE_NFS
[plugin "events-kafka"]
sendAsync = true
bootstrapServers = $BROKER_HOST:$BROKER_PORT
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 98d1320..3fc57ae 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
@@ -14,6 +14,7 @@
package com.googlesource.gerrit.plugins.multisite.validation;
+import static com.googlesource.gerrit.plugins.multisite.validation.ProjectVersionRefUpdate.MULTI_SITE_VERSIONING_REF;
import static com.googlesource.gerrit.plugins.replication.pull.PullReplicationLogger.repLog;
import com.gerritforge.gerrit.globalrefdb.GlobalRefDbLockException;
@@ -64,6 +65,9 @@
.filter(ref -> !hasBeenRemovedFromGlobalRefDb(projectName, ref))
.filter(
ref -> {
+ if (shouldNotBeTrackedAnymoreOnGlobalRefDb(ref)) {
+ return true;
+ }
Optional<ObjectId> localRefOid =
getLocalSha1IfEqualsToExistingGlobalRefDb(
repository, projectName, refDb, ref, true);
@@ -76,7 +80,7 @@
ref,
oid.getName()));
- return localRefOid.isEmpty();
+ return !localRefOid.isPresent();
})
.collect(Collectors.toSet());
} catch (IOException ioe) {
@@ -87,6 +91,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);
+ }
+
/* If the ref to fetch has been set to all zeros on the global-refdb, it means
* that whatever is the situation locally, we do not need to fetch it:
* - If the remote still has it, fetching it will be useless because the global
@@ -129,7 +146,7 @@
.orElse(false))
.map(Ref::getObjectId);
- if (localRefObjectId.isEmpty() && retryWithRandomSleep) {
+ if (!localRefObjectId.isPresent() && retryWithRandomSleep) {
randomSleepForMitigatingConditionWhereLocalRefHaveJustBeenChanged(
projectName, localRefObjectId, ref);
localRefObjectId =
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImplTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImplTest.java
index 09f8f59..c612119 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImplTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImplTest.java
@@ -30,7 +30,6 @@
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectIdRef;
import org.eclipse.jgit.lib.Ref;
-import org.eclipse.jgit.lib.RefDatabase;
import org.eclipse.jgit.lib.Repository;
import org.junit.Before;
import org.junit.Test;
@@ -45,13 +44,11 @@
GroupCheckerImpl objectUnderTest;
@Mock private GitRepositoryManager repoManagerMock;
- @Mock private RefDatabase refDatabaseMock;
@Mock private Repository repoMock;
@Before
public void setUp() throws Exception {
doReturn(repoMock).when(repoManagerMock).openRepository(allUsers);
- doReturn(refDatabaseMock).when(repoMock).getRefDatabase();
objectUnderTest = new GroupCheckerImpl(repoManagerMock, allUsers);
}
@@ -118,6 +115,6 @@
throws IOException {
String groupRefName = RefNames.refsGroups(AccountGroup.uuid(groupUUID.toString()));
ObjectIdRef.Unpeeled aRef = new ObjectIdRef.Unpeeled(Ref.Storage.LOOSE, groupRefName, objectId);
- doReturn(objectId == null ? null : aRef).when(refDatabaseMock).exactRef(groupRefName);
+ doReturn(objectId == null ? null : aRef).when(repoMock).exactRef(groupRefName);
}
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilterTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilterTest.java
index 9a7a3b3..e09f6f6 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilterTest.java
@@ -170,6 +170,24 @@
}
@Test
+ public void shouldNotFilterOutWhenRefsMultisiteVersionIsPresentInSharedRefDb() throws Exception {
+ String refsMultisiteVersionRef = ProjectVersionRefUpdate.MULTI_SITE_VERSIONING_REF;
+ RevCommit multiSiteVersionRef = newRef(refsMultisiteVersionRef);
+
+ doReturn(Optional.of(multiSiteVersionRef.getId().getName()))
+ .when(sharedRefDatabaseMock)
+ .get(eq(projectName), eq(refsMultisiteVersionRef), eq(String.class));
+
+ Set<String> refsToFetch = Set.of(refsMultisiteVersionRef);
+
+ MultisiteReplicationFetchFilter fetchFilter =
+ new MultisiteReplicationFetchFilter(sharedRefDatabaseMock, gitRepositoryManager, config);
+ Set<String> filteredRefsToFetch = fetchFilter.filter(project, refsToFetch);
+
+ assertThat(filteredRefsToFetch).hasSize(1);
+ }
+
+ @Test
public void shouldFilterOutWhenRefIsDeletedInTheSharedRefDb() throws Exception {
String temporaryOutdated = "refs/heads/temporaryOutdated";
newRef(temporaryOutdated);