Disable commitWithin when running Reindex

Disable the 'commitWithin' from within Reindex by overriding
the configuration with '-1'. Treat negative values as the
original behavior, auto-flushing but not auto-committing, which
is the least safe but the most efficient for reindexing the
entire site. 

Change-Id: Ifdba797bee871d2a3d8928810a6304bacb850c8c
This commit is contained in:
Bruce Zu
2014-03-21 10:03:05 +08:00
committed by David Pursehouse
parent 3daa739e13
commit af058e6dd3
5 changed files with 64 additions and 48 deletions

View File

@@ -95,6 +95,7 @@ public class Reindex extends SiteProgram {
throw die("index.type must be configured (or not SQL)");
}
limitThreads();
disableLuceneAutomaticCommit();
if (version == null) {
version = ChangeSchemas.getLatest().getVersion();
}
@@ -162,6 +163,15 @@ public class Reindex extends SiteProgram {
return dbInjector.createChildInjector(modules);
}
private void disableLuceneAutomaticCommit() {
Config cfg =
dbInjector.getInstance(Key.get(Config.class, GerritServerConfig.class));
if (IndexModule.getIndexType(dbInjector) == IndexType.LUCENE) {
cfg.setLong("index", "changes_open", "commitWithin", -1);
cfg.setLong("index", "changes_closed", "commitWithin", -1);
}
}
private class ReviewDbModule extends LifecycleModule {
@Override
protected void configure() {