Skip to content

Commit fb36f00

Browse files
author
Michael Sokolov
committed
Revert "Index open performs version check on each segment, ignores indexCreatedVersionMajor (#14607)"
This reverts commit 3bf1011.
1 parent 3bf1011 commit fb36f00

File tree

3 files changed

+21
-34
lines changed

3 files changed

+21
-34
lines changed

lucene/CHANGES.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ Other
131131
* GITHUB#14761: Use more Comparators for PriorityQueue implementations. (Simon Cooper)
132132
* GITHUB#14817: Refactor some complex uses of PriorityQueue to use Comparators. (Simon Cooper)
133133

134-
* GITHUB#14607: Index open performs version check on each segment, ignores indexCreatedVersionMajor (Rahul Goswami)
135134
======================= Lucene 10.4.0 =======================
136135

137136
API Changes

lucene/backward-codecs/src/test/org/apache/lucene/backward_index/TestBasicBackwardsCompatibility.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ public void testFailOpenOldIndex() throws IOException {
864864
assertTrue(
865865
ex.getMessage()
866866
.contains(
867-
"This Lucene version only supports indexes with major version "
867+
"This Lucene version only supports indexes created with major version "
868868
+ Version.LATEST.major
869869
+ " or later"));
870870
// now open with allowed min version

lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,30 @@ public static final SegmentInfos readCommit(
346346
input);
347347
}
348348

349+
if (indexCreatedVersion < minSupportedMajorVersion) {
350+
throw new IndexFormatTooOldException(
351+
input,
352+
"Index created with Lucene "
353+
+ indexCreatedVersion
354+
+ ".x is not supported by Lucene "
355+
+ Version.LATEST
356+
+ ". This Lucene version only supports indexes created with major version "
357+
+ minSupportedMajorVersion
358+
+ " or later (found: "
359+
+ indexCreatedVersion
360+
+ ", minimum: "
361+
+ minSupportedMajorVersion
362+
+ "). To resolve this issue: (1) Re-index your data using Lucene "
363+
+ Version.LATEST.major
364+
+ ".x, or (2) Use an older Lucene version that supports your index format.");
365+
}
366+
349367
SegmentInfos infos = new SegmentInfos(indexCreatedVersion);
350368
infos.id = id;
351369
infos.generation = generation;
352370
infos.lastGeneration = generation;
353371
infos.luceneVersion = luceneVersion;
354-
parseSegmentInfos(directory, input, infos, format, minSupportedMajorVersion);
372+
parseSegmentInfos(directory, input, infos, format);
355373
return infos;
356374

357375
} catch (Throwable t) {
@@ -367,12 +385,7 @@ public static final SegmentInfos readCommit(
367385
}
368386

369387
private static void parseSegmentInfos(
370-
Directory directory,
371-
DataInput input,
372-
SegmentInfos infos,
373-
int format,
374-
int minSupportedMajorVersion)
375-
throws IOException {
388+
Directory directory, DataInput input, SegmentInfos infos, int format) throws IOException {
376389
infos.version = CodecUtil.readBELong(input);
377390
// System.out.println("READ sis version=" + infos.version);
378391
infos.counter = input.readVLong();
@@ -389,7 +402,6 @@ private static void parseSegmentInfos(
389402
}
390403

391404
long totalDocs = 0;
392-
393405
for (int seg = 0; seg < numSegments; seg++) {
394406
String segName = input.readString();
395407
byte[] segmentID = new byte[StringHelper.ID_LENGTH];
@@ -483,30 +495,6 @@ private static void parseSegmentInfos(
483495
+ infos.indexCreatedVersionMajor,
484496
input);
485497
}
486-
487-
int createdOrSegmentMinVersion =
488-
info.getMinVersion() == null
489-
? infos.indexCreatedVersionMajor
490-
: info.getMinVersion().major;
491-
492-
// version >=7 are expected to record minVersion
493-
if (info.getMinVersion() == null || info.getMinVersion().major < minSupportedMajorVersion) {
494-
throw new IndexFormatTooOldException(
495-
input,
496-
"Index has segments derived from Lucene version "
497-
+ createdOrSegmentMinVersion
498-
+ ".x and is not supported by Lucene "
499-
+ Version.LATEST
500-
+ ". This Lucene version only supports indexes with major version "
501-
+ minSupportedMajorVersion
502-
+ " or later (found: "
503-
+ createdOrSegmentMinVersion
504-
+ ", minimum supported: "
505-
+ minSupportedMajorVersion
506-
+ "). To resolve this issue re-index your data using Lucene "
507-
+ minSupportedMajorVersion
508-
+ ".x or later.");
509-
}
510498
}
511499

512500
infos.userData = input.readMapOfStrings();

0 commit comments

Comments
 (0)