Store mergeable field from cache in index

Eventually this will no longer be part of the serialized change proto,
and even with the cache it is still expensive to check mergeability
for each change in a list of search results, as the submit type must
still be checked in order to look up the mergeability.

The new MERGEABLE field now loads from the cache, although ChangeJson
and several other callers still depend on the field in Change. This
will facilitate index schema upgrades, in that a full reindex will
also populate the persistent cache.

While we're at it, upgrade Lucene to 4.10.1, which contains some
important stability bugfixes[1].

[1] http://lucene.apache.org/core/4_10_1/changes/Changes.html#v4.10.1

Change-Id: I166b85f91bd596a3f0295616c2e72853b692dd54
This commit is contained in:
Dave Borowitz
2014-10-17 14:51:03 -07:00
parent 094ee4daa1
commit 2ab1af186e
14 changed files with 228 additions and 89 deletions

View File

@@ -21,39 +21,24 @@ import com.google.common.collect.Sets;
import com.google.gerrit.common.Die;
import com.google.gerrit.lifecycle.LifecycleManager;
import com.google.gerrit.lucene.LuceneIndexModule;
import com.google.gerrit.pgm.util.BatchGitModule;
import com.google.gerrit.pgm.util.BatchProgramModule;
import com.google.gerrit.pgm.util.SiteProgram;
import com.google.gerrit.pgm.util.ThreadLimiter;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.cache.h2.DefaultCacheFactory;
import com.google.gerrit.server.change.MergeabilityCache;
import com.google.gerrit.server.change.MergeabilityChecker;
import com.google.gerrit.server.change.MergeabilityChecksExecutor;
import com.google.gerrit.server.change.MergeabilityChecksExecutor.Priority;
import com.google.gerrit.server.change.PatchSetInserter;
import com.google.gerrit.server.config.FactoryModule;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.git.MergeUtil;
import com.google.gerrit.server.git.WorkQueue;
import com.google.gerrit.server.index.ChangeBatchIndexer;
import com.google.gerrit.server.index.ChangeIndex;
import com.google.gerrit.server.index.ChangeSchemas;
import com.google.gerrit.server.index.IndexCollection;
import com.google.gerrit.server.index.IndexModule;
import com.google.gerrit.server.index.IndexModule.IndexType;
import com.google.gerrit.server.mail.ReplacePatchSetSender;
import com.google.gerrit.server.notedb.NoteDbModule;
import com.google.gerrit.solr.SolrIndexModule;
import com.google.inject.AbstractModule;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.util.Providers;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.ProgressMonitor;
@@ -146,15 +131,6 @@ public class Reindex extends SiteProgram {
}
modules.add(changeIndexModule);
modules.add(dbInjector.getInstance(BatchProgramModule.class));
modules.add(new AbstractModule() {
@Override
protected void configure() {
if (recheckMergeable) {
install(new MergeabilityModule());
}
}
});
return dbInjector.createChildInjector(modules);
}
@@ -167,38 +143,6 @@ public class Reindex extends SiteProgram {
}
}
private static class MergeabilityModule extends FactoryModule {
@Override
public void configure() {
factory(PatchSetInserter.Factory.class);
bind(ReplacePatchSetSender.Factory.class).toProvider(
Providers.<ReplacePatchSetSender.Factory>of(null));
factory(MergeUtil.Factory.class);
install(new NoteDbModule());
install(new BatchGitModule());
install(new DefaultCacheFactory.Module());
install(MergeabilityCache.module());
}
@Provides
@Singleton
@MergeabilityChecksExecutor(Priority.BACKGROUND)
public WorkQueue.Executor createMergeabilityChecksExecutor(
WorkQueue queues) {
return queues.createQueue(1, "MergeabilityChecks");
}
@Provides
@Singleton
@MergeabilityChecksExecutor(Priority.INTERACTIVE)
public WorkQueue.Executor createInteractiveMergeabilityChecksExecutor(
@MergeabilityChecksExecutor(Priority.BACKGROUND)
WorkQueue.Executor bg) {
return bg;
}
}
private int indexAll() throws Exception {
ReviewDb db = sysInjector.getInstance(ReviewDb.class);
ProgressMonitor pm = new TextProgressMonitor();