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
Use the smallest version rather than the default version #11475
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -756,13 +756,13 @@ public org.apache.lucene.util.Version upgrade(UpgradeRequest upgrade) { | |
} | ||
|
||
public org.apache.lucene.util.Version minimumCompatibleVersion() { | ||
org.apache.lucene.util.Version luceneVersion = org.apache.lucene.util.Version.LUCENE_3_6; | ||
org.apache.lucene.util.Version luceneVersion = null; | ||
for(Segment segment : engine().segments()) { | ||
if (luceneVersion.onOrAfter(segment.getVersion())) { | ||
if (luceneVersion == null || luceneVersion.onOrAfter(segment.getVersion())) { | ||
luceneVersion = segment.getVersion(); | ||
} | ||
} | ||
return luceneVersion; | ||
return luceneVersion == null ? Version.indexCreated(indexSettings).luceneVersion : luceneVersion; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK but this indexCreated is an immutable thing in ES right? So this means a user can never upgrade an empty index? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if there are no docs in the index it won't do anything here yes! in this case we should make this method more low level - I will fix that too |
||
|
||
public SnapshotIndexCommit snapshotIndex() throws EngineException { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,11 @@ | |
|
||
package org.elasticsearch.rest.action.admin.indices.upgrade; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.bwcompat.StaticIndexBackwardCompatibilityTest; | ||
import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
import org.elasticsearch.index.IndexService; | ||
import org.elasticsearch.indices.IndicesService; | ||
|
||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; | ||
|
||
|
@@ -28,20 +32,23 @@ public class UpgradeReallyOldIndexTest extends StaticIndexBackwardCompatibilityT | |
public void testUpgrade_0_20() throws Exception { | ||
String indexName = "test"; | ||
loadIndex("index-0.20.zip", indexName); | ||
|
||
assertMinVersion(indexName, org.apache.lucene.util.Version.parse("3.6.2")); | ||
assertTrue(UpgradeTest.hasAncientSegments(client(), indexName)); | ||
UpgradeTest.assertNotUpgraded(client(), indexName); | ||
assertNoFailures(client().admin().indices().prepareUpgrade(indexName).setUpgradeOnlyAncientSegments(true).get()); | ||
assertFalse(UpgradeTest.hasAncientSegments(client(), indexName)); | ||
|
||
// This index has entirely ancient segments so the whole index should now be upgraded: | ||
UpgradeTest.assertUpgraded(client(), indexName); | ||
assertEquals(Version.CURRENT.luceneVersion.toString(), client().admin().indices().prepareGetSettings(indexName).get().getSetting(indexName, IndexMetaData.SETTING_VERSION_MINIMUM_COMPATIBLE)); | ||
assertMinVersion(indexName, Version.CURRENT.luceneVersion); | ||
|
||
} | ||
|
||
public void testUpgradeMixed_0_20_6_and_0_90_6() throws Exception { | ||
String indexName = "index-0.20.6-and-0.90.6"; | ||
loadIndex(indexName + ".zip", indexName); | ||
|
||
assertMinVersion(indexName, org.apache.lucene.util.Version.parse("3.6.2")); | ||
// Has ancient segments?: | ||
assertTrue(UpgradeTest.hasAncientSegments(client(), indexName)); | ||
|
||
|
@@ -59,5 +66,18 @@ public void testUpgradeMixed_0_20_6_and_0_90_6() throws Exception { | |
|
||
// We succeeded in upgrading only the ancient segments but leaving the "merely old" ones untouched: | ||
assertTrue(UpgradeTest.hasOldButNotAncientSegments(client(), indexName)); | ||
assertEquals(org.apache.lucene.util.Version.LUCENE_4_5_1.toString(), client().admin().indices().prepareGetSettings(indexName).get().getSetting(indexName, IndexMetaData.SETTING_VERSION_MINIMUM_COMPATIBLE)); | ||
assertMinVersion(indexName, org.apache.lucene.util.Version.LUCENE_4_5_1); | ||
|
||
} | ||
|
||
private void assertMinVersion(String index, org.apache.lucene.util.Version version) { | ||
for (IndicesService services : internalCluster().getInstances(IndicesService.class)) { | ||
IndexService indexService = services.indexService(index); | ||
if (indexService != null) { | ||
assertEquals(version, indexService.shard(0).minimumCompatibleVersion()); | ||
} | ||
} | ||
|
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused about this assert. especially given the comments above it. If this minimum version is a lucene version, should it not be the oldest lucene version? In this case the ancient segments will be upgraded, but the "merely old" ones will still be there, so I can't see it being CURRENT. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the index is empty and just a commit point?