Allow disabling ReindexAfterRefUpdate
While it's a nice idea in theory to recheck the mergeable bit on all open changes when the branch advances, or to reindex everything when label definitions change, in practice it can be quite taxing on a live server with thousands of open changes on an active project. Allow admins to disable this if necessary. Change-Id: I551a2afa9572e71e36b5344a059346eb92cb2fcf
This commit is contained in:
@@ -2613,6 +2613,19 @@ are the same.
|
||||
+
|
||||
Defaults to 1024.
|
||||
|
||||
[[index.reindexAfterRefUpdate]]index.reindexAfterRefUpdate::
|
||||
+
|
||||
Whether to reindex all affected open changes after a ref is updated. This
|
||||
includes reindexing all open changes to recompute the "mergeable" bit every time
|
||||
the destination branch moves, as well as reindexing changes to take into account
|
||||
new project configuration (e.g. label definitions).
|
||||
+
|
||||
Leaving this enabled may result in fresher results, but may cause performance
|
||||
problems if there are lots of open changes on a project whose branches advance
|
||||
frequently.
|
||||
+
|
||||
Defaults to true.
|
||||
|
||||
==== Lucene configuration
|
||||
|
||||
Open and closed changes are indexed in separate indexes named
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.git.QueueProvider.QueueType;
|
||||
import com.google.gerrit.server.index.IndexExecutor;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
@@ -41,6 +42,7 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -53,9 +55,11 @@ public class ReindexAfterRefUpdate implements GitReferenceUpdatedListener {
|
||||
private final ChangeIndexCollection indexes;
|
||||
private final ChangeNotes.Factory notesFactory;
|
||||
private final ListeningExecutorService executor;
|
||||
private final boolean enabled;
|
||||
|
||||
@Inject
|
||||
ReindexAfterRefUpdate(
|
||||
@GerritServerConfig Config cfg,
|
||||
OneOffRequestContext requestContext,
|
||||
Provider<InternalChangeQuery> queryProvider,
|
||||
ChangeIndexer.Factory indexerFactory,
|
||||
@@ -68,11 +72,13 @@ public class ReindexAfterRefUpdate implements GitReferenceUpdatedListener {
|
||||
this.indexes = indexes;
|
||||
this.notesFactory = notesFactory;
|
||||
this.executor = executor;
|
||||
this.enabled = cfg.getBoolean("index", null, "reindexAfterRefUpdate", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGitReferenceUpdated(final Event event) {
|
||||
if (event.getRefName().startsWith(RefNames.REFS_CHANGES)
|
||||
if (!enabled
|
||||
|| event.getRefName().startsWith(RefNames.REFS_CHANGES)
|
||||
|| event.getRefName().startsWith(RefNames.REFS_DRAFT_COMMENTS)
|
||||
|| event.getRefName().startsWith(RefNames.REFS_USERS)) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user