Add config option to disable online reindexing
Change-Id: I18c48008778df86355a0bd57977e13e080f5fc90
This commit is contained in:
@@ -2176,6 +2176,18 @@ If not set or set to a negative value, defaults to using the same
|
|||||||
thread pool as interactive operations (unless
|
thread pool as interactive operations (unless
|
||||||
link:#changeMerge.threadPoolSize[changeMerge.threadPoolSize] is set).
|
link:#changeMerge.threadPoolSize[changeMerge.threadPoolSize] is set).
|
||||||
|
|
||||||
|
[[index.onlineUpgrade]]index.onlineUpgrade::
|
||||||
|
+
|
||||||
|
Whether to upgrade to new index schema versions while the server is
|
||||||
|
running. This is recommended as it prevents additional downtime during
|
||||||
|
Gerrit version upgrades (avoiding the need for an offline reindex step
|
||||||
|
using Reindex), but can add additional server load during the upgrade.
|
||||||
|
+
|
||||||
|
If set to false, there is no way to upgrade the index schema to take
|
||||||
|
advantage of new search features without restarting the server.
|
||||||
|
+
|
||||||
|
Defaults to true.
|
||||||
|
|
||||||
==== Lucene configuration
|
==== Lucene configuration
|
||||||
|
|
||||||
Open and closed changes are indexed in separate indexes named
|
Open and closed changes are indexed in separate indexes named
|
||||||
|
@@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.google.gerrit.extensions.events.LifecycleListener;
|
import com.google.gerrit.extensions.events.LifecycleListener;
|
||||||
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.gerrit.server.config.SitePaths;
|
import com.google.gerrit.server.config.SitePaths;
|
||||||
import com.google.gerrit.server.index.ChangeSchemas;
|
import com.google.gerrit.server.index.ChangeSchemas;
|
||||||
import com.google.gerrit.server.index.IndexCollection;
|
import com.google.gerrit.server.index.IndexCollection;
|
||||||
@@ -93,9 +94,11 @@ class LuceneVersionManager implements LifecycleListener {
|
|||||||
private final LuceneChangeIndex.Factory indexFactory;
|
private final LuceneChangeIndex.Factory indexFactory;
|
||||||
private final IndexCollection indexes;
|
private final IndexCollection indexes;
|
||||||
private final OnlineReindexer.Factory reindexerFactory;
|
private final OnlineReindexer.Factory reindexerFactory;
|
||||||
|
private final boolean onlineUpgrade;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
LuceneVersionManager(
|
LuceneVersionManager(
|
||||||
|
@GerritServerConfig Config cfg,
|
||||||
SitePaths sitePaths,
|
SitePaths sitePaths,
|
||||||
LuceneChangeIndex.Factory indexFactory,
|
LuceneChangeIndex.Factory indexFactory,
|
||||||
IndexCollection indexes,
|
IndexCollection indexes,
|
||||||
@@ -104,6 +107,7 @@ class LuceneVersionManager implements LifecycleListener {
|
|||||||
this.indexFactory = indexFactory;
|
this.indexFactory = indexFactory;
|
||||||
this.indexes = indexes;
|
this.indexes = indexes;
|
||||||
this.reindexerFactory = reindexerFactory;
|
this.reindexerFactory = reindexerFactory;
|
||||||
|
this.onlineUpgrade = cfg.getBoolean("index", null, "onlineUpgrade", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -133,7 +137,7 @@ class LuceneVersionManager implements LifecycleListener {
|
|||||||
if (v.schema == null) {
|
if (v.schema == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (write.isEmpty()) {
|
if (write.isEmpty() && onlineUpgrade) {
|
||||||
write.add(v);
|
write.add(v);
|
||||||
}
|
}
|
||||||
if (v.ready) {
|
if (v.ready) {
|
||||||
@@ -162,7 +166,7 @@ class LuceneVersionManager implements LifecycleListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int latest = write.get(0).version;
|
int latest = write.get(0).version;
|
||||||
if (latest != search.version) {
|
if (onlineUpgrade && latest != search.version) {
|
||||||
reindexerFactory.create(latest).start();
|
reindexerFactory.create(latest).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user