Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-3449

QueryComponent.doFieldSortValues throw ArrayIndexOutOfBoundsException when has maxDoc=0 Segment

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • 3.5, 3.6
    • 3.6.3
    • search
    • None

    Description

      have index

      Segment name=_9, offest=[docBase=0, maxDoc=245] idx=0
      Segment name=_a, offest=[docBase=245, maxDoc=3] idx=1
      Segment name=_b, offest=[docBase=248, maxDoc=0] idx=2
      Segment name=_c, offest=[docBase=248, maxDoc=1] idx=3
      Segment name=_d, offest=[docBase=249, maxDoc=0] idx=4
      Segment name=_e, offest=[docBase=249, maxDoc=1] idx=5
      Segment name=_f, offest=[docBase=250, maxDoc=0] idx=6
      Segment name=_g, offest=[docBase=250, maxDoc=3] idx=7
      Segment name=_h, offest=[docBase=253, maxDoc=0] idx=8
      

      maxDoc=0 's Segment maybe create by mergeIndexes。(can make sure maxDoc=0 's segment not merge, but when couldn't control merge indexes)

      when use fsv=true get sort values, hit docId=249 throw ArrayIndexOutOfBoundsException

      2012-5-11 14:28:28 org.apache.solr.common.SolrException log
      ERROR: java.lang.ArrayIndexOutOfBoundsException: 0
              at org.apache.lucene.search.FieldComparator$LongComparator.copy(FieldComparator.java:600)
              at org.apache.solr.handler.component.QueryComponent.doFieldSortValues(QueryComponent.java:463)
              at org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:400)
      

      reason:

      //idx              0    1    2    3    4    5    6    7    8
      //int[] maxDocs={245,   3,   0,   1,   0,   1,   0,   3,   0};
      int[] offsets = {  0, 245, 248, 248, 249, 249, 250, 250, 253};
      org.apache.solr.search.SolrIndexReader.readerIndex(249, offsets) return idx=4 not 5。
      

      correct idx=5。

      patch

      Index: solr/core/src/java/org/apache/solr/search/SolrIndexReader.java
      ===================================================================
      --- solr/core/src/java/org/apache/solr/search/SolrIndexReader.java	(revision 1337028)
      +++ solr/core/src/java/org/apache/solr/search/SolrIndexReader.java	(working copy)
      @@ -138,6 +138,16 @@
             }
             else {
               // exact match on the offset.
      +    	//skip equal offest
      +      	for(int i=mid+1; i<=high; i++) {
      +      		if(doc == offsets[i]) {
      +      			//skip offests[i] == doc
      +          		mid = i;
      +      		} else {
      +      			//stop skip offest
      +      			break;
      +      		}
      +      	}
               return mid;
             }
           }
      

      Attachments

        1. SOLR-3449.patch
          2 kB
          Linbin Chen

        Activity

          People

            Unassigned Unassigned
            chenlb Linbin Chen
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: