You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2017/07/06 14:40:21 UTC

lucene-solr:master: LUCENE-7837: Use indexCreatedVersionMajor to fail opening too old indices.

Repository: lucene-solr
Updated Branches:
  refs/heads/master 77ee4ddb9 -> 43442a635


LUCENE-7837: Use indexCreatedVersionMajor to fail opening too old indices.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/43442a63
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/43442a63
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/43442a63

Branch: refs/heads/master
Commit: 43442a6354b911be51be601f035cdcb8fd072b50
Parents: 77ee4dd
Author: Adrien Grand <jp...@gmail.com>
Authored: Thu Jul 6 16:39:21 2017 +0200
Committer: Adrien Grand <jp...@gmail.com>
Committed: Thu Jul 6 16:39:21 2017 +0200

----------------------------------------------------------------------
 lucene/CHANGES.txt                                     |  9 ++++++++-
 .../src/java/org/apache/lucene/index/SegmentInfos.java | 13 +++++++++----
 2 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/43442a63/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 5c7431e..85b4957 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -4,7 +4,14 @@ For more information on past and future Lucene versions, please see:
 http://s.apache.org/luceneversions
 
 ======================= Lucene 8.0.0 =======================
-(No Changes)
+
+Changes in Runtime Behavior
+
+* LUCENE-7837: Indices that were created before the previous major version
+  will now fail to open even if they have been merged with the previous major
+  version. (Adrien Grand)
+
+
 
 ======================= Lucene 7.1.0 =======================
 (No Changes)

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/43442a63/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
index 9f1450b..23ad9fb 100644
--- a/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
+++ b/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java
@@ -306,12 +306,17 @@ public final class SegmentInfos implements Cloneable, Iterable<SegmentCommitInfo
     CodecUtil.checkIndexHeaderSuffix(input, Long.toString(generation, Character.MAX_RADIX));
 
     Version luceneVersion = Version.fromBits(input.readVInt(), input.readVInt(), input.readVInt());
-    if (luceneVersion.onOrAfter(Version.LUCENE_7_0_0) == false) {
-      // TODO: should we check indexCreatedVersion instead?
-      throw new IndexFormatTooOldException(input, "this index is too old (version: " + luceneVersion + ")");
+    int indexCreatedVersion = input.readVInt();
+    if (luceneVersion.major < indexCreatedVersion) {
+      throw new CorruptIndexException("Creation version [" + indexCreatedVersion
+          + ".x] can't be greater than the version that wrote the segment infos: [" + luceneVersion + "]" , input);
     }
 
-    int indexCreatedVersion = input.readVInt();
+    if (indexCreatedVersion < Version.LATEST.major - 1) {
+      throw new IndexFormatTooOldException(input, "This index was initially created with Lucene "
+          + indexCreatedVersion + ".x while the current version is " + Version.LATEST
+          + " and Lucene only supports reading the current and previous major versions.");
+    }
 
     SegmentInfos infos = new SegmentInfos(indexCreatedVersion);
     infos.id = id;