You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Ufuk YILMAZ via java-user <ja...@lucene.apache.org> on 2026/06/26 12:21:05 UTC

ArrayIndexOutOfBoundsException during DocValues facet count calculation

I've debugged a weird error I'm getting from Solr, which turned out to 
be coming from lucene.

For a particular search (it doesn't happen with other searches as far as 
I could see), during the facet calculation (DocValues facet), at this 
line:

https://github.com/apache/lucene/blob/f965e930673c1f5cb478dc6a8907f5fc4ef7b539/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java#L297

   private int nextSetBitInRange(int start, int upperBound) {
     // Depends on the ghost bits being clear!
     assert start >= 0 && start < numBits : "index=" + start + ", 
numBits=" + numBits;
     assert start < upperBound : "index=" + start + ", upperBound=" + 
upperBound;
     assert upperBound <= numBits : "upperBound=" + upperBound + ", 
numBits=" + numBits;
     int i = start >> 6;
     long word = bits[i] >> start; // skip all the bits to the right of 
index

"start" is 46536, "upperBound" is 46492 and "i" is 727:

long word = bits[i] >> start; // skip all the bits to the right of index

the above line throws an exception:

java.lang.ArrayIndexOutOfBoundsException: Index 727 out of bounds for 
length 727

I don't know if I can reproduce this error with a few documents and a 
simple search, because it is pretty elusive. For example, if I just 
reindex, the exception goes away.

When I use another facet calculation algorihtm in Solr (e.g. "enum"), 
the error goes away. It's only when docvalues is used.

Could you point me in a direction to maybe better reproduce it with a 
specific set of documents, or debug it better?

--Ufuk

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: ArrayIndexOutOfBoundsException during DocValues facet count calculation

Posted by Egor Potemkin <eg...@gmail.com>.
Hi Ufuk,

Thanks for the details.

Could you please share which Lucene/Solr version you are running, and the
full stack trace if you have it? Also, if you can reproduce this again,
could you try running with assertions enabled? The assertions just above
the failing line should print useful debug information.

Thanks,
Egor

On Fri, 26 Jun 2026 at 15:22, Ufuk YILMAZ via java-user <
java-user@lucene.apache.org> wrote:

> I've debugged a weird error I'm getting from Solr, which turned out to
> be coming from lucene.
>
> For a particular search (it doesn't happen with other searches as far as
> I could see), during the facet calculation (DocValues facet), at this
> line:
>
>
> https://github.com/apache/lucene/blob/f965e930673c1f5cb478dc6a8907f5fc4ef7b539/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java#L297
>
>    private int nextSetBitInRange(int start, int upperBound) {
>      // Depends on the ghost bits being clear!
>      assert start >= 0 && start < numBits : "index=" + start + ",
> numBits=" + numBits;
>      assert start < upperBound : "index=" + start + ", upperBound=" +
> upperBound;
>      assert upperBound <= numBits : "upperBound=" + upperBound + ",
> numBits=" + numBits;
>      int i = start >> 6;
>      long word = bits[i] >> start; // skip all the bits to the right of
> index
>
> "start" is 46536, "upperBound" is 46492 and "i" is 727:
>
> long word = bits[i] >> start; // skip all the bits to the right of index
>
> the above line throws an exception:
>
> java.lang.ArrayIndexOutOfBoundsException: Index 727 out of bounds for
> length 727
>
> I don't know if I can reproduce this error with a few documents and a
> simple search, because it is pretty elusive. For example, if I just
> reindex, the exception goes away.
>
> When I use another facet calculation algorihtm in Solr (e.g. "enum"),
> the error goes away. It's only when docvalues is used.
>
> Could you point me in a direction to maybe better reproduce it with a
> specific set of documents, or debug it better?
>
> --Ufuk
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: ArrayIndexOutOfBoundsException during DocValues facet count calculation

Posted by Uwe Schindler via java-user <ja...@lucene.apache.org>.
Hi,

actually, FixedBitSet is a general purpose class provided by Apache 
Lucene. For performance reasons, this class does not do any parameter 
checks (only with the assertion that is not ran on production code). 
Therefor the exception happens later than it would happen in 
conventional "safe" bitsets.

As we do not have a stack trace in whcih context the error occurs, we 
can't figure out if the method is called from Lucene or Solr code. As it 
is facetting code it can come from both, because Solr also uses that bitset.

To get a better insight:

  * enable assertions in production code: Run Solr's JVM with "-ea"
    parameter to enable assertions. Add this to the command line options
    (next to garbage collector) and try again. Please be aware that this
    slows down a lot!
  * give us a full stack trace

Uwe

Am 26.06.2026 um 14:21 schrieb Ufuk YILMAZ via java-user:
> I've debugged a weird error I'm getting from Solr, which turned out to 
> be coming from lucene.
>
> For a particular search (it doesn't happen with other searches as far 
> as I could see), during the facet calculation (DocValues facet), at 
> this line:
>
> https://github.com/apache/lucene/blob/f965e930673c1f5cb478dc6a8907f5fc4ef7b539/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java#L297 
>
>
>   private int nextSetBitInRange(int start, int upperBound) {
>     // Depends on the ghost bits being clear!
>     assert start >= 0 && start < numBits : "index=" + start + ", 
> numBits=" + numBits;
>     assert start < upperBound : "index=" + start + ", upperBound=" + 
> upperBound;
>     assert upperBound <= numBits : "upperBound=" + upperBound + ", 
> numBits=" + numBits;
>     int i = start >> 6;
>     long word = bits[i] >> start; // skip all the bits to the right of 
> index
>
> "start" is 46536, "upperBound" is 46492 and "i" is 727:
>
> long word = bits[i] >> start; // skip all the bits to the right of index
>
> the above line throws an exception:
>
> java.lang.ArrayIndexOutOfBoundsException: Index 727 out of bounds for 
> length 727
>
> I don't know if I can reproduce this error with a few documents and a 
> simple search, because it is pretty elusive. For example, if I just 
> reindex, the exception goes away.
>
> When I use another facet calculation algorihtm in Solr (e.g. "enum"), 
> the error goes away. It's only when docvalues is used.
>
> Could you point me in a direction to maybe better reproduce it with a 
> specific set of documents, or debug it better?
>
> --Ufuk
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
-- 
Uwe Schindler
Achterdiek 19, D-28357 Bremen
https://www.thetaphi.de
eMail:uwe@thetaphi.de