Skip to content

Commit 2d88691

Browse files
authored
remove backcompat handling of 6.2.x versions (#42044)
relates to refactoring initiative #41164.
1 parent e8b85c9 commit 2d88691

File tree

20 files changed

+58
-203
lines changed

20 files changed

+58
-203
lines changed

server/src/main/java/org/elasticsearch/ElasticsearchException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ private enum ElasticsearchExceptionHandle {
10061006
UNKNOWN_NAMED_OBJECT_EXCEPTION(org.elasticsearch.common.xcontent.UnknownNamedObjectException.class,
10071007
org.elasticsearch.common.xcontent.UnknownNamedObjectException::new, 148, UNKNOWN_VERSION_ADDED),
10081008
TOO_MANY_BUCKETS_EXCEPTION(MultiBucketConsumerService.TooManyBucketsException.class,
1009-
MultiBucketConsumerService.TooManyBucketsException::new, 149, Version.V_6_2_0),
1009+
MultiBucketConsumerService.TooManyBucketsException::new, 149, UNKNOWN_VERSION_ADDED),
10101010
COORDINATION_STATE_REJECTED_EXCEPTION(org.elasticsearch.cluster.coordination.CoordinationStateRejectedException.class,
10111011
org.elasticsearch.cluster.coordination.CoordinationStateRejectedException::new, 150, Version.V_7_0_0),
10121012
SNAPSHOT_IN_PROGRESS_EXCEPTION(org.elasticsearch.snapshots.SnapshotInProgressException.class,

server/src/main/java/org/elasticsearch/Version.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ public class Version implements Comparable<Version>, ToXContentFragment {
4848
public static final Version V_EMPTY = new Version(V_EMPTY_ID, org.apache.lucene.util.Version.LATEST);
4949
// The below version is missing from the 7.3 JAR
5050
private static final org.apache.lucene.util.Version LUCENE_7_2_1 = org.apache.lucene.util.Version.fromBits(7, 2, 1);
51-
public static final int V_6_2_0_ID = 6020099;
52-
public static final Version V_6_2_0 = new Version(V_6_2_0_ID, LUCENE_7_2_1);
53-
public static final int V_6_2_1_ID = 6020199;
54-
public static final Version V_6_2_1 = new Version(V_6_2_1_ID, LUCENE_7_2_1);
55-
public static final int V_6_2_2_ID = 6020299;
56-
public static final Version V_6_2_2 = new Version(V_6_2_2_ID, LUCENE_7_2_1);
57-
public static final int V_6_2_3_ID = 6020399;
58-
public static final Version V_6_2_3 = new Version(V_6_2_3_ID, LUCENE_7_2_1);
59-
public static final int V_6_2_4_ID = 6020499;
60-
public static final Version V_6_2_4 = new Version(V_6_2_4_ID, LUCENE_7_2_1);
6151
public static final int V_6_3_0_ID = 6030099;
6252
public static final Version V_6_3_0 = new Version(V_6_3_0_ID, org.apache.lucene.util.Version.LUCENE_7_3_1);
6353
public static final int V_6_3_1_ID = 6030199;
@@ -176,16 +166,6 @@ public static Version fromId(int id) {
176166
return V_6_3_1;
177167
case V_6_3_0_ID:
178168
return V_6_3_0;
179-
case V_6_2_4_ID:
180-
return V_6_2_4;
181-
case V_6_2_3_ID:
182-
return V_6_2_3;
183-
case V_6_2_2_ID:
184-
return V_6_2_2;
185-
case V_6_2_1_ID:
186-
return V_6_2_1;
187-
case V_6_2_0_ID:
188-
return V_6_2_0;
189169
case V_EMPTY_ID:
190170
return V_EMPTY;
191171
default:

server/src/main/java/org/elasticsearch/index/store/Store.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,23 +1550,8 @@ public void trimUnsafeCommits(final long lastSyncedGlobalCheckpoint, final long
15501550
final IndexCommit lastIndexCommitCommit = existingCommits.get(existingCommits.size() - 1);
15511551
final String translogUUID = lastIndexCommitCommit.getUserData().get(Translog.TRANSLOG_UUID_KEY);
15521552
final IndexCommit startingIndexCommit;
1553-
// We may not have a safe commit if an index was create before v6.2; and if there is a snapshotted commit whose translog
1554-
// are not retained but max_seqno is at most the global checkpoint, we may mistakenly select it as a starting commit.
1555-
// To avoid this issue, we only select index commits whose translog are fully retained.
1556-
if (indexVersionCreated.before(org.elasticsearch.Version.V_6_2_0)) {
1557-
final List<IndexCommit> recoverableCommits = new ArrayList<>();
1558-
for (IndexCommit commit : existingCommits) {
1559-
if (minRetainedTranslogGen <= Long.parseLong(commit.getUserData().get(Translog.TRANSLOG_GENERATION_KEY))) {
1560-
recoverableCommits.add(commit);
1561-
}
1562-
}
1563-
assert recoverableCommits.isEmpty() == false : "No commit point with translog found; " +
1564-
"commits [" + existingCommits + "], minRetainedTranslogGen [" + minRetainedTranslogGen + "]";
1565-
startingIndexCommit = CombinedDeletionPolicy.findSafeCommitPoint(recoverableCommits, lastSyncedGlobalCheckpoint);
1566-
} else {
1567-
// TODO: Asserts the starting commit is a safe commit once peer-recovery sets global checkpoint.
1568-
startingIndexCommit = CombinedDeletionPolicy.findSafeCommitPoint(existingCommits, lastSyncedGlobalCheckpoint);
1569-
}
1553+
// TODO: Asserts the starting commit is a safe commit once peer-recovery sets global checkpoint.
1554+
startingIndexCommit = CombinedDeletionPolicy.findSafeCommitPoint(existingCommits, lastSyncedGlobalCheckpoint);
15701555

15711556
if (translogUUID.equals(startingIndexCommit.getUserData().get(Translog.TRANSLOG_UUID_KEY)) == false) {
15721557
throw new IllegalStateException("starting commit translog uuid ["

server/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,6 @@ static final class PreSyncedFlushResponse extends TransportResponse {
594594
this.existingSyncId = existingSyncId;
595595
}
596596

597-
boolean includeNumDocs(Version version) {
598-
return version.onOrAfter(Version.V_6_2_2);
599-
}
600-
601597
boolean includeExistingSyncId(Version version) {
602598
return version.onOrAfter(Version.V_6_3_0);
603599
}
@@ -606,11 +602,7 @@ boolean includeExistingSyncId(Version version) {
606602
public void readFrom(StreamInput in) throws IOException {
607603
super.readFrom(in);
608604
commitId = new Engine.CommitId(in);
609-
if (includeNumDocs(in.getVersion())) {
610-
numDocs = in.readInt();
611-
} else {
612-
numDocs = UNKNOWN_NUM_DOCS;
613-
}
605+
numDocs = in.readInt();
614606
if (includeExistingSyncId(in.getVersion())) {
615607
existingSyncId = in.readOptionalString();
616608
}
@@ -620,9 +612,7 @@ public void readFrom(StreamInput in) throws IOException {
620612
public void writeTo(StreamOutput out) throws IOException {
621613
super.writeTo(out);
622614
commitId.writeTo(out);
623-
if (includeNumDocs(out.getVersion())) {
624-
out.writeInt(numDocs);
625-
}
615+
out.writeInt(numDocs);
626616
if (includeExistingSyncId(out.getVersion())) {
627617
out.writeOptionalString(existingSyncId);
628618
}

server/src/main/java/org/elasticsearch/search/slice/SliceBuilder.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,14 @@ public SliceBuilder(String field, int id, int max) {
106106

107107
public SliceBuilder(StreamInput in) throws IOException {
108108
String field = in.readString();
109-
if ("_uid".equals(field) && in.getVersion().before(Version.V_6_3_0)) {
110-
// This is safe because _id and _uid are handled the same way in #toFilter
111-
field = IdFieldMapper.NAME;
112-
}
113109
this.field = field;
114110
this.id = in.readVInt();
115111
this.max = in.readVInt();
116112
}
117113

118114
@Override
119115
public void writeTo(StreamOutput out) throws IOException {
120-
if (IdFieldMapper.NAME.equals(field) && out.getVersion().before(Version.V_6_3_0)) {
121-
out.writeString("_uid");
122-
} else {
123-
out.writeString(field);
124-
}
116+
out.writeString(field);
125117
out.writeVInt(id);
126118
out.writeVInt(max);
127119
}

server/src/test/java/org/elasticsearch/BuildTests.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,29 +199,24 @@ public void testSerializationBWC() throws IOException {
199199
randomAlphaOfLength(6), randomAlphaOfLength(6), randomBoolean(), randomAlphaOfLength(6)));
200200

201201
final List<Version> versions = Version.getDeclaredVersions(Version.class);
202-
final Version pre63Version = randomFrom(versions.stream().filter(v -> v.before(Version.V_6_3_0)).collect(Collectors.toList()));
203202
final Version post63Pre67Version = randomFrom(versions.stream()
204203
.filter(v -> v.onOrAfter(Version.V_6_3_0) && v.before(Version.V_6_7_0)).collect(Collectors.toList()));
205204
final Version post67Pre70Version = randomFrom(versions.stream()
206205
.filter(v -> v.onOrAfter(Version.V_6_7_0) && v.before(Version.V_7_0_0)).collect(Collectors.toList()));
207206
final Version post70Version = randomFrom(versions.stream().filter(v -> v.onOrAfter(Version.V_7_0_0)).collect(Collectors.toList()));
208207

209-
final WriteableBuild pre63 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, pre63Version);
210208
final WriteableBuild post63pre67 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post63Pre67Version);
211209
final WriteableBuild post67pre70 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post67Pre70Version);
212210
final WriteableBuild post70 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post70Version);
213211

214-
assertThat(pre63.build.flavor(), equalTo(Build.Flavor.OSS));
215212
assertThat(post63pre67.build.flavor(), equalTo(dockerBuild.build.flavor()));
216213
assertThat(post67pre70.build.flavor(), equalTo(dockerBuild.build.flavor()));
217214
assertThat(post70.build.flavor(), equalTo(dockerBuild.build.flavor()));
218215

219-
assertThat(pre63.build.type(), equalTo(Build.Type.UNKNOWN));
220216
assertThat(post63pre67.build.type(), equalTo(Build.Type.TAR));
221217
assertThat(post67pre70.build.type(), equalTo(dockerBuild.build.type()));
222218
assertThat(post70.build.type(), equalTo(dockerBuild.build.type()));
223219

224-
assertThat(pre63.build.getQualifiedVersion(), equalTo(pre63Version.toString()));
225220
assertThat(post63pre67.build.getQualifiedVersion(), equalTo(post63Pre67Version.toString()));
226221
assertThat(post67pre70.build.getQualifiedVersion(), equalTo(post67Pre70Version.toString()));
227222
assertThat(post70.build.getQualifiedVersion(), equalTo(dockerBuild.build.getQualifiedVersion()));

server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public void testCircuitBreakingException() throws IOException {
366366
}
367367

368368
public void testTooManyBucketsException() throws IOException {
369-
Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_2_0, Version.CURRENT);
369+
Version version = VersionUtils.randomCompatibleVersion(random(), Version.CURRENT);
370370
MultiBucketConsumerService.TooManyBucketsException ex =
371371
serialize(new MultiBucketConsumerService.TooManyBucketsException("Too many buckets", 100), version);
372372
assertEquals("Too many buckets", ex.getMessage());

server/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
import java.io.IOException;
3939
import java.util.ArrayList;
40-
import java.util.Collections;
4140
import java.util.List;
4241

4342
import static org.elasticsearch.common.lucene.uid.VersionsAndSeqNoResolver.loadDocIdAndVersion;
@@ -189,23 +188,16 @@ public void testCacheFilterReader() throws Exception {
189188
}
190189

191190
public void testLuceneVersionOnUnknownVersions() {
192-
List<Version> allVersions = VersionUtils.allVersions();
193-
194-
// should have the same Lucene version as the latest 6.x version
195-
Version version = Version.fromString("6.88.50");
196-
assertEquals(allVersions.get(Collections.binarySearch(allVersions, Version.V_7_0_0) - 1).luceneVersion,
197-
version.luceneVersion);
198-
199191
// between two known versions, should use the lucene version of the previous version
200-
version = Version.fromString("6.2.50");
201-
assertEquals(VersionUtils.getPreviousVersion(Version.V_6_2_4).luceneVersion, version.luceneVersion);
192+
Version version = VersionUtils.getPreviousVersion(Version.CURRENT);
193+
assertEquals(Version.fromId(version.id + 100).luceneVersion, version.luceneVersion);
202194

203195
// too old version, major should be the oldest supported lucene version minus 1
204196
version = Version.fromString("5.2.1");
205197
assertEquals(VersionUtils.getFirstVersion().luceneVersion.major - 1, version.luceneVersion.major);
206198

207199
// future version, should be the same version as today
208-
version = Version.fromString("8.77.1");
200+
version = Version.fromId(Version.CURRENT.id + 100);
209201
assertEquals(Version.CURRENT.luceneVersion, version.luceneVersion);
210202
}
211203
}

server/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public void testThatInstancesAreCachedAndReused() {
7575
PreBuiltAnalyzers.STANDARD.getAnalyzer(VersionUtils.randomPreviousCompatibleVersion(random(), Version.CURRENT)));
7676

7777
// Same Lucene version should be cached:
78-
assertSame(PreBuiltAnalyzers.STOP.getAnalyzer(Version.V_6_2_1),
79-
PreBuiltAnalyzers.STOP.getAnalyzer(Version.V_6_2_2));
78+
assertSame(PreBuiltAnalyzers.STOP.getAnalyzer(Version.fromString("5.0.0")),
79+
PreBuiltAnalyzers.STOP.getAnalyzer(Version.fromString("5.0.1")));
8080
}
8181

8282
public void testThatAnalyzersAreUsedInMapping() throws IOException {

server/src/test/java/org/elasticsearch/search/slice/SliceBuilderTests.java

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import org.elasticsearch.index.Index;
5454
import org.elasticsearch.index.IndexSettings;
5555
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
56-
import org.elasticsearch.index.mapper.IdFieldMapper;
5756
import org.elasticsearch.index.mapper.MappedFieldType;
5857
import org.elasticsearch.index.query.QueryShardContext;
5958
import org.elasticsearch.index.query.Rewriteable;
@@ -63,6 +62,7 @@
6362
import org.elasticsearch.search.internal.AliasFilter;
6463
import org.elasticsearch.search.internal.ShardSearchRequest;
6564
import org.elasticsearch.test.ESTestCase;
65+
import org.elasticsearch.test.VersionUtils;
6666

6767
import java.io.IOException;
6868
import java.util.ArrayList;
@@ -455,21 +455,6 @@ public void testToFilterDeprecationMessage() throws IOException {
455455
}
456456
}
457457

458-
public void testSerializationBackcompat() throws IOException {
459-
SliceBuilder sliceBuilder = new SliceBuilder(1, 5);
460-
assertEquals(IdFieldMapper.NAME, sliceBuilder.getField());
461-
462-
SliceBuilder copy62 = copyWriteable(sliceBuilder,
463-
new NamedWriteableRegistry(Collections.emptyList()),
464-
SliceBuilder::new, Version.V_6_2_0);
465-
assertEquals(sliceBuilder, copy62);
466-
467-
SliceBuilder copy63 = copyWriteable(copy62,
468-
new NamedWriteableRegistry(Collections.emptyList()),
469-
SliceBuilder::new, Version.V_6_3_0);
470-
assertEquals(sliceBuilder, copy63);
471-
}
472-
473458
public void testToFilterWithRouting() throws IOException {
474459
Directory dir = new RAMDirectory();
475460
try (IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())))) {
@@ -489,15 +474,14 @@ public void testToFilterWithRouting() throws IOException {
489474
when(clusterService.operationRouting()).thenReturn(routing);
490475
when(clusterService.getSettings()).thenReturn(Settings.EMPTY);
491476
try (IndexReader reader = DirectoryReader.open(dir)) {
492-
QueryShardContext context = createShardContext(Version.CURRENT, reader, "field", DocValuesType.SORTED, 5, 0);
477+
Version version = VersionUtils.randomCompatibleVersion(random(), Version.CURRENT);
478+
QueryShardContext context = createShardContext(version, reader, "field", DocValuesType.SORTED, 5, 0);
493479
SliceBuilder builder = new SliceBuilder("field", 6, 10);
494480
String[] routings = new String[] { "foo" };
495-
Query query = builder.toFilter(clusterService, createRequest(1, routings, null), context, Version.CURRENT);
481+
Query query = builder.toFilter(clusterService, createRequest(1, routings, null), context, version);
496482
assertEquals(new DocValuesSliceQuery("field", 6, 10), query);
497-
query = builder.toFilter(clusterService, createRequest(1, Strings.EMPTY_ARRAY, "foo"), context, Version.CURRENT);
483+
query = builder.toFilter(clusterService, createRequest(1, Strings.EMPTY_ARRAY, "foo"), context, version);
498484
assertEquals(new DocValuesSliceQuery("field", 6, 10), query);
499-
query = builder.toFilter(clusterService, createRequest(1, Strings.EMPTY_ARRAY, "foo"), context, Version.V_6_2_0);
500-
assertEquals(new DocValuesSliceQuery("field", 1, 2), query);
501485
}
502486
}
503487
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/UpdateJobAction.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ public void readFrom(StreamInput in) throws IOException {
9292
super.readFrom(in);
9393
jobId = in.readString();
9494
update = new JobUpdate(in);
95-
if (in.getVersion().onOrAfter(Version.V_6_2_2)) {
96-
isInternal = in.readBoolean();
97-
} else {
98-
isInternal = false;
99-
}
95+
isInternal = in.readBoolean();
10096
if (in.getVersion().onOrAfter(Version.V_6_3_0) && in.getVersion().before(Version.V_7_0_0)) {
10197
in.readBoolean(); // was waitForAck
10298
}
@@ -107,9 +103,7 @@ public void writeTo(StreamOutput out) throws IOException {
107103
super.writeTo(out);
108104
out.writeString(jobId);
109105
update.writeTo(out);
110-
if (out.getVersion().onOrAfter(Version.V_6_2_2)) {
111-
out.writeBoolean(isInternal);
112-
}
106+
out.writeBoolean(isInternal);
113107
if (out.getVersion().onOrAfter(Version.V_6_3_0) && out.getVersion().before(Version.V_7_0_0)) {
114108
out.writeBoolean(false); // was waitForAck
115109
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/UpdateProcessAction.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
package org.elasticsearch.xpack.core.ml.action;
77

8-
import org.elasticsearch.Version;
98
import org.elasticsearch.action.Action;
109
import org.elasticsearch.action.ActionRequestBuilder;
1110
import org.elasticsearch.action.support.tasks.BaseTasksResponse;
@@ -121,10 +120,8 @@ public Request(StreamInput in) throws IOException {
121120
if (in.readBoolean()) {
122121
detectorUpdates = in.readList(JobUpdate.DetectorUpdate::new);
123122
}
124-
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
125-
filter = in.readOptionalWriteable(MlFilter::new);
126-
updateScheduledEvents = in.readBoolean();
127-
}
123+
filter = in.readOptionalWriteable(MlFilter::new);
124+
updateScheduledEvents = in.readBoolean();
128125
}
129126

130127
@Override
@@ -136,10 +133,8 @@ public void writeTo(StreamOutput out) throws IOException {
136133
if (hasDetectorUpdates) {
137134
out.writeList(detectorUpdates);
138135
}
139-
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
140-
out.writeOptionalWriteable(filter);
141-
out.writeBoolean(updateScheduledEvents);
142-
}
136+
out.writeOptionalWriteable(filter);
137+
out.writeBoolean(updateScheduledEvents);
143138
}
144139

145140
public Request(String jobId, ModelPlotConfig modelPlotConfig, List<JobUpdate.DetectorUpdate> detectorUpdates, MlFilter filter,

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,7 @@ public DatafeedConfig(StreamInput in) throws IOException {
222222
}
223223
this.scrollSize = in.readOptionalVInt();
224224
this.chunkingConfig = in.readOptionalWriteable(ChunkingConfig::new);
225-
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
226-
this.headers = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readString));
227-
} else {
228-
this.headers = Collections.emptyMap();
229-
}
225+
this.headers = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readString));
230226
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
231227
delayedDataCheckConfig = in.readOptionalWriteable(DelayedDataCheckConfig::new);
232228
} else {
@@ -432,9 +428,7 @@ public void writeTo(StreamOutput out) throws IOException {
432428
}
433429
out.writeOptionalVInt(scrollSize);
434430
out.writeOptionalWriteable(chunkingConfig);
435-
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
436-
out.writeMap(headers, StreamOutput::writeString, StreamOutput::writeString);
437-
}
431+
out.writeMap(headers, StreamOutput::writeString, StreamOutput::writeString);
438432
if (out.getVersion().onOrAfter(Version.V_6_6_0)) {
439433
out.writeOptionalWriteable(delayedDataCheckConfig);
440434
}

0 commit comments

Comments
 (0)