You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Cassandra Targett (Jira)" <ji...@apache.org> on 2020/02/14 20:06:00 UTC
[jira] [Commented] (LUCENE-9222) Detect upgrades with non-default
formats
[ https://issues.apache.org/jira/browse/LUCENE-9222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17037263#comment-17037263 ]
Cassandra Targett commented on LUCENE-9222:
-------------------------------------------
I'm trying to wrap my head around this, but don't really get the idea. Is this proposal effectively saying that any index using a non-default codec will always throw a IndexFormatTooOldException on upgrade, even between minor versions? Or is it more about improving the type of error that is thrown if the non-default codec has been changed after an upgrade?
> Detect upgrades with non-default formats
> ----------------------------------------
>
> Key: LUCENE-9222
> URL: https://issues.apache.org/jira/browse/LUCENE-9222
> Project: Lucene - Core
> Issue Type: Wish
> Reporter: Adrien Grand
> Priority: Minor
>
> Lucene doesn't give any backward-compatibility guarantees with non-default formats, but doesn't try to detect such misuse either, and a couple users fell in this trap over the years, see e.g. SOLR-14254.
> What about dynamically creating the version number of the index format based on the current Lucene version, so that Lucene would fail with an IndexFormatTooOldException with non-default formats instead of a confusing CorruptIndexException. The change would consist of doing something like that for all our non-default index formats:
> {code}
> diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java
> index fcc0d00a593..18b35760aec 100644
> --- a/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java
> +++ b/lucene/codecs/src/java/org/apache/lucene/codecs/memory/FSTTermsWriter.java
> @@ -41,6 +41,7 @@ import org.apache.lucene.util.BytesRef;
> import org.apache.lucene.util.FixedBitSet;
> import org.apache.lucene.util.IOUtils;
> import org.apache.lucene.util.IntsRefBuilder;
> +import org.apache.lucene.util.Version;
> import org.apache.lucene.util.fst.FSTCompiler;
> import org.apache.lucene.util.fst.FST;
> import org.apache.lucene.util.fst.Util;
> @@ -123,7 +124,7 @@ import org.apache.lucene.util.fst.Util;
> public class FSTTermsWriter extends FieldsConsumer {
> static final String TERMS_EXTENSION = "tfp";
> static final String TERMS_CODEC_NAME = "FSTTerms";
> - public static final int TERMS_VERSION_START = 2;
> + public static final int TERMS_VERSION_START = (Version.LATEST.major << 16) | (Version.LATEST.minor << 8) | Version.LATEST.bugfix;
> public static final int TERMS_VERSION_CURRENT = TERMS_VERSION_START;
>
> final PostingsWriterBase postingsWriter;
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org