Merge branch 'stable-2.14'

* stable-2.14:
  Disable auto-reindexing if stale during online reindex
  ChangeIndexer#reindexAfterIndexUpdate -> autoReindexIfStale
  Align lib modules load injector on Jetty and external containers
  Update git submodules

Change-Id: Ic9932140c82f749c800862178cfb889e8b661a55
This commit is contained in:
David Pursehouse
2017-06-24 11:30:40 +09:00
7 changed files with 21 additions and 10 deletions

View File

@@ -2691,6 +2691,15 @@ frequently.
+
Defaults to true.
[[index.autoReindexIfStale]]index.autoReindexIfStale::
+
Whether to automatically check if a document became stale in the index
immediately after indexing it. If false, there is a race condition during two
simultaneous writes that may cause one of the writes to not be reflected in the
index. The check to avoid this does consume some resources.
+
Defaults to true.
==== Lucene configuration
Open and closed changes are indexed in separate indexes named

View File

@@ -515,7 +515,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
}
@Test
@GerritConfig(name = "index.testAutoReindexIfStale", value = "false")
@GerritConfig(name = "index.autoReindexIfStale", value = "false")
public void getRelatedForStaleChange() throws Exception {
RevCommit c1_1 = commitBuilder().add("a.txt", "1").message("subject: 1").create();

View File

@@ -120,7 +120,7 @@ public class ChangeRebuilderIT extends AbstractDaemonTest {
// unintentional auto-rebuilding of the change in NoteDb during the read
// path of the reindex-if-stale check. For the purposes of this test, we
// want precise control over when auto-rebuilding happens.
cfg.setBoolean("index", null, "testAutoReindexIfStale", false);
cfg.setBoolean("index", null, "autoReindexIfStale", false);
return cfg;
}

View File

@@ -47,6 +47,7 @@ import com.google.gerrit.pgm.util.ErrorLogFile;
import com.google.gerrit.pgm.util.LogFileCompressor;
import com.google.gerrit.pgm.util.RuntimeShutdown;
import com.google.gerrit.pgm.util.SiteProgram;
import com.google.gerrit.server.LibModuleLoader;
import com.google.gerrit.server.StartupChecks;
import com.google.gerrit.server.account.InternalAccountDirectory;
import com.google.gerrit.server.cache.h2.DefaultCacheFactory;
@@ -440,6 +441,7 @@ public class Daemon extends SiteProgram {
if (!slave) {
modules.add(new ChangeCleanupRunner.Module());
}
modules.addAll(LibModuleLoader.loadModules(cfgInjector));
return cfgInjector.createChildInjector(modules);
}

View File

@@ -84,8 +84,7 @@ public class Reindex extends SiteProgram {
globalConfig = dbInjector.getInstance(Key.get(Config.class, GerritServerConfig.class));
threads = ThreadLimiter.limitThreads(dbInjector, threads);
checkNotSlaveMode();
disableLuceneAutomaticCommit();
disableChangeCache();
overrideConfig();
LifecycleManager dbManager = new LifecycleManager();
dbManager.add(dbInjector);
dbManager.start();
@@ -177,15 +176,18 @@ public class Reindex extends SiteProgram {
return dbInjector.createChildInjector(modules);
}
private void disableLuceneAutomaticCommit() {
private void overrideConfig() {
// Disable auto-commit for speed; committing will happen at the end of the process.
if (IndexModule.getIndexType(dbInjector) == IndexType.LUCENE) {
globalConfig.setLong("index", "changes_open", "commitWithin", -1);
globalConfig.setLong("index", "changes_closed", "commitWithin", -1);
}
}
private void disableChangeCache() {
// Disable change cache.
globalConfig.setLong("cache", "changes", "maximumWeight", 0);
// Disable auto-reindexing if stale, since there are no concurrent writes to race with.
globalConfig.setBoolean("index", null, "autoReindexIfStale", false);
}
private <K, V, I extends Index<K, V>> boolean reindex(IndexDefinition<K, V, I> def)

View File

@@ -24,7 +24,6 @@ import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.metrics.DisabledMetricMaker;
import com.google.gerrit.metrics.MetricMaker;
import com.google.gerrit.metrics.dropwizard.DropWizardMetricMaker;
import com.google.gerrit.server.LibModuleLoader;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.GerritServerConfigModule;
import com.google.gerrit.server.config.SitePath;
@@ -185,7 +184,6 @@ public abstract class SiteProgram extends AbstractProgram {
modules.add(new SchemaModule());
modules.add(cfgInjector.getInstance(GitRepositoryManagerModule.class));
modules.add(new ConfigNotesMigration.Module());
modules.addAll(LibModuleLoader.loadModules(cfgInjector));
try {
return Guice.createInjector(PRODUCTION, modules);

View File

@@ -164,7 +164,7 @@ public class ChangeIndexer {
}
private static boolean autoReindexIfStale(Config cfg) {
return cfg.getBoolean("index", null, "testAutoReindexIfStale", true);
return cfg.getBoolean("index", null, "autoReindexIfStale", true);
}
/**