[ 
https://issues.apache.org/jira/browse/LUCENE-6019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14180413#comment-14180413
 ] 

Michael McCandless commented on LUCENE-6019:
--------------------------------------------

Grrrrrr!

DefaultIndexingChain has this nice (wrong) comment:

{noformat}
    // This will throw an exc if the caller tried to
    // change the DV type for the field:
    fp.fieldInfo.setDocValuesType(dvType);
    if (hasDocValues == false) {
      fieldInfos.globalFieldNumbers.setDocValuesType(fp.fieldInfo.number, 
fp.fieldInfo.name, dvType);
    }
{noformat}

... it's wrong because in FieldInfos.setDocValuesType we have this:

{noformat}
    synchronized void setDocValuesType(int number, String name, DocValuesType 
dvType) {
      assert containsConsistent(number, name, dvType);
      docValuesType.put(name, dvType);
    }
{noformat}

So indeed it only throws exc when assertions are enabled.

bq.  NOTE: this only fails if you run without assertions which I think lucene 
should do in CI once in a while too.

+1, I think we should do this first.  We have existing tests that would have 
caught this bug had we already done this...

> IndexWriter allows to add same field with different docvlaues type 
> -------------------------------------------------------------------
>
>                 Key: LUCENE-6019
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6019
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/index
>    Affects Versions: 4.10.1
>            Reporter: Simon Willnauer
>            Priority: Critical
>             Fix For: 4.10.2, 5.0
>
>
> IndexWriter checks if the DV types are consitent in multiple places but if 
> due to some problems in Elasticsearch users where able to add the same field 
> with different DV types causing merges to fail. Yet I was able to reduce this 
> to a lucene testcase but I was puzzled since it always failed. Yet, I had to 
> run it without assertions and that cause the bug to happen. I can add field 
> foo with BINARY and SORTED_SET causing a merge to fail. Here is a gist 
> https://gist.github.com/s1monw/8707f924b76ba40ee5f3 / 
> https://github.com/elasticsearch/elasticsearch/issues/8009 
> While this is certainly a problem in Elasticsearch Lucene also allows to 
> corrupt an index due to user error which I think should be prevented. NOTE: 
> this only fails if you run without assertions which I think lucene should do 
> in CI once in a while too.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to