Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore 3x segment upgrade if unneeded #11383

Merged
merged 1 commit into from May 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -152,7 +152,12 @@ public final class EngineConfig {
/**
* Creates a new {@link org.elasticsearch.index.engine.EngineConfig}
*/
public EngineConfig(ShardId shardId, boolean optimizeAutoGenerateId, ThreadPool threadPool, ShardIndexingService indexingService, IndexSettingsService indexSettingsService, IndicesWarmer warmer, Store store, SnapshotDeletionPolicy deletionPolicy, Translog translog, MergePolicyProvider mergePolicyProvider, MergeSchedulerProvider mergeScheduler, Analyzer analyzer, Similarity similarity, CodecService codecService, Engine.FailedEngineListener failedEngineListener) {
public EngineConfig(ShardId shardId, boolean optimizeAutoGenerateId, ThreadPool threadPool,
ShardIndexingService indexingService, IndexSettingsService indexSettingsService,
IndicesWarmer warmer, Store store, SnapshotDeletionPolicy deletionPolicy,
Translog translog, MergePolicyProvider mergePolicyProvider,
MergeSchedulerProvider mergeScheduler, Analyzer analyzer, Similarity similarity,
CodecService codecService, Engine.FailedEngineListener failedEngineListener) {
this.shardId = shardId;
this.optimizeAutoGenerateId = optimizeAutoGenerateId;
this.threadPool = threadPool;
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/org/elasticsearch/index/engine/InternalEngine.java
Expand Up @@ -31,6 +31,8 @@
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchIllegalStateException;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.routing.operation.hash.djb.DjbHashFunction;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.lease.Releasable;
Expand Down Expand Up @@ -118,7 +120,20 @@ public InternalEngine(EngineConfig engineConfig) throws EngineException {
boolean success = false;
try {
try {
upgrade3xSegments(store);
boolean autoUpgrade = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use Version#indexCreated(Settings) here instead?

try {
// If the index was created on 0.20.7 (Lucene 3.x) or earlier,
// it needs to be upgraded
autoUpgrade = Version.indexCreated(engineConfig.getIndexSettings()).onOrBefore(Version.V_0_20_7);
} catch (ElasticsearchIllegalStateException e) {
// we weren't able to parse the version, that's fine
}
if (autoUpgrade) {
logger.debug("[{}] checking for 3x segments to upgrade", shardId);
upgrade3xSegments(store);
} else {
logger.debug("[{}] skipping check for 3x segments", shardId);
}
} catch (IOException ex) {
throw new EngineCreationFailureException(shardId, "failed to upgrade 3x segments", ex);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/elasticsearch/index/shard/IndexShard.java
Expand Up @@ -57,7 +57,6 @@
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.AbstractRefCounted;
import org.elasticsearch.common.util.concurrent.FutureUtils;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.aliases.IndexAliasesService;
Expand Down Expand Up @@ -246,8 +245,9 @@ public IndexShard(ShardId shardId, @IndexSettings Settings indexSettings, IndexS
/* create engine config */
this.config = new EngineConfig(shardId,
indexSettings.getAsBoolean(EngineConfig.INDEX_OPTIMIZE_AUTOGENERATED_ID_SETTING, false),
threadPool, indexingService, indexSettingsService, warmer, store, deletionPolicy, translog, mergePolicyProvider, mergeScheduler,
analysisService.defaultIndexAnalyzer(), similarityService.similarity(), codecService, failedEngineListener);
threadPool, indexingService, indexSettingsService, warmer, store, deletionPolicy,
translog, mergePolicyProvider, mergeScheduler, analysisService.defaultIndexAnalyzer(),
similarityService.similarity(), codecService, failedEngineListener);

logger.debug("state: [CREATED]");

Expand Down
Expand Up @@ -73,7 +73,6 @@
import org.elasticsearch.index.settings.IndexSettingsService;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.store.DirectoryService;
import org.elasticsearch.index.store.DirectoryUtils;
import org.elasticsearch.index.store.Store;
import org.elasticsearch.index.store.distributor.LeastUsedDistributor;
import org.elasticsearch.index.translog.Translog;
Expand Down