apache / apache/lucene

IllegalArgumentException from ByteBufferIndexInput.buildSlice [LUCENE-5658]

Open
#6,720 12 comments 0 reactions 0 assignees View on GitHub
affects-version:4.8 legacy-jira-priority:Major module:core/store type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

I've received an email with the following stacktrace:

```
Exception in thread "Lucene Merge Thread #73" org.apache.lucene.index.MergePolicy$MergeException: java.lang.IllegalArgumentException
at org.apache.lucene.index.ConcurrentMergeScheduler.handleMergeException(ConcurrentMergeScheduler.java:545)
at org.apache.lucene.index.ConcurrentMergeScheduler$MergeThread.run(ConcurrentMergeScheduler.java:518)
Caused by: java.lang.IllegalArgumentException
at java.nio.Buffer.limit(Buffer.java:278)
at org.apache.lucene.store.ByteBufferIndexInput.buildSlice(ByteBufferIndexInput.java:259)
at org.apache.lucene.store.ByteBufferIndexInput.buildSlice(ByteBufferIndexInput.java:230)
at org.apache.lucene.store.ByteBufferIndexInput.clone(ByteBufferIndexInput.java:187)
at org.apache.lucene.store.MMapDirectory$1.openFullSlice(MMapDirectory.java:211)
at org.apache.lucene.store.CompoundFileDirectory.readEntries(CompoundFileDirectory.java:138)
at org.apache.lucene.store.CompoundFileDirectory.(CompoundFileDirectory.java:105)
at org.apache.lucene.index.SegmentReader.readFieldInfos(SegmentReader.java:209)
at org.apache.lucene.index.SegmentReader.(SegmentReader.java:99)
at org.apache.lucene.index.ReadersAndUpdates.getReader(ReadersAndUpdates.java:142)
at org.apache.lucene.index.ReadersAndUpdates.getReaderForMerge(ReadersAndUpdates.java:624)
at org.apache.lucene.index.IndexWriter.mergeMiddle(IndexWriter.java:4068)
at org.apache.lucene.index.IndexWriter.merge(IndexWriter.java:3728)
at org.apache.lucene.index.ConcurrentMergeScheduler.doMerge(ConcurrentMergeScheduler.java:405)
at org.apache.lucene.index.ConcurrentMergeScheduler$MergeThread.run(ConcurrentMergeScheduler.java:482)
```

According to the email, it happens randomly while indexing Wikipedia, on 4.8.0. As far as I understood, the indexer creates 4 indexes in parallel, by a total of 48 threads. Each index is created in a separate directory, and there's no sharing of MP or MS instances between the writers (in fact, default settings are used). This could explain the `Lucene Merge Thread #73`. The indexing process ends w/ a `forceMerge(1)`. If that call is omitted, the exception doesn't reproduce. Also, since it doesn't happen always, there's no simple testcase which reproduces.

I've asked the reporter to add more info to the issue, but opening the issue now so we could check and hopefully fix before 4.8.1.

I checked the stacktrace against trunk, but not all the lines align (e.g. `at org.apache.lucene.store.MMapDirectory$1.openFullSlice(MMapDirectory.java:211)` is only in 4.8), but I haven't dug deeper yet...

---
Migrated from [LUCENE-5658](https://issues.apache.org/jira/browse/LUCENE-5658) by Shai Erera (@shaie), updated Jun 01 2014

Contributor guide

Open the contributing guide

Research direction

Start with ByteBufferIndexInput.buildSlice and its callers in MMapDirectory, CompoundFileDirectory, and IndexWriter's merge path; compare the 4.8.0 stack trace with trunk. Try the reported parallel Wikipedia indexing workflow with forceMerge(1). Done means identifying and fixing the intermittent IllegalArgumentException, ideally with a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.