Index change asynchronously upon refs replicated event Do not block the replication thread for performing a change indexing, as it may slowdown the incoming operation on the sender side. When the refs are replicated through apply-object or sync replication, the incoming thread is blocked until all listeners are complete. The reindexing of a change may take a considerable amount of time, especially when there are Prolog rules involved. The ref is replicated therefore there is no need to block the incoming operation waiting for the reindex to complete. Change-Id: I49279262ea68bb6118ea76ff3123a7538dfe72fc
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/event/FetchRefReplicatedEventHandler.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/event/FetchRefReplicatedEventHandler.java index a618e16..9ee1e8e 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/event/FetchRefReplicatedEventHandler.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/event/FetchRefReplicatedEventHandler.java
@@ -52,7 +52,7 @@ fetchRefReplicatedEvent.getRefName(), projectNameKey.get()); Change.Id changeId = Change.Id.fromRef(fetchRefReplicatedEvent.getRefName()); if (changeId != null) { - changeIndexer.index(projectNameKey, changeId); + changeIndexer.indexAsync(projectNameKey, changeId); } else { logger.atWarning().log( "Couldn't get changeId from refName. Skipping indexing of change %s for project %s",
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/event/FetchRefReplicatedEventHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/event/FetchRefReplicatedEventHandlerTest.java index 81a4fc0..c4c35ed 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/event/FetchRefReplicatedEventHandlerTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/event/FetchRefReplicatedEventHandlerTest.java
@@ -58,7 +58,7 @@ sourceUri, ReplicationState.RefFetchResult.SUCCEEDED, RefUpdate.Result.FAST_FORWARD)); - verify(changeIndexerMock, times(1)).index(eq(projectNameKey), eq(changeId)); + verify(changeIndexerMock, times(1)).indexAsync(eq(projectNameKey), eq(changeId)); } finally { Context.unsetLocalEvent(); }