Issue Details (XML | Word | Printable)

Key: LUCENE-1430
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Michael McCandless
Reporter: Michael McCandless
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Lucene - Java

IndexReader.open(String|File) may incorrectly throw AlreadyClosedException

Created: 29/Oct/08 07:04 PM   Updated: 25/Sep/09 04:23 PM
Return to search
Component/s: Index
Affects Version/s: 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4
Fix Version/s: 2.4.1, 2.9

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works LUCENE-1430.patch 2008-10-29 07:12 PM Michael McCandless 4 kB

Lucene Fields: New
Resolution Date: 19/Feb/09 09:47 AM


 Description  « Hide
Spinoff from here:

http://www.nabble.com/Runtime-exception-when-creating-IndexSearcher-to20226279.html

If you open an IndexSearcher/Reader, passing in String or File, then
closeDirectory is set to true in the reader.

If the index has a single segment, then SegmentReader.get is used to
open the index. If an IOException is hit in there, the SegmentReader
closes itself and then closes the directory since closeDirectory is
true.

The problem is, the retry logic in SegmentInfos (to look for another
segments_N to try) kicks in and hits an AlreadyClosedException,
masking the original root cause.

Workaround is to separately get the Directory using
FSDirectory.getDirectory, and then instantiate IndexSearcher/Reader
from that.

This manifests as masking the root cause of a corrupted single-segment
index with a confusing AlreadyClosedException. You could also hit
the false exception if the writer was in the process of committing
(ie, a retry was really needed) or if there is some transient IO
problem opening the index (eg too many open files).



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #709456 Fri Oct 31 16:09:12 UTC 2008 mikemccand LUCENE-1430: don't throw false AlreadyClosedException when IndexReader.open hits IOException on first try opening index
Files Changed
MODIFY /lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java
MODIFY /lucene/java/trunk/src/java/org/apache/lucene/index/DirectoryIndexReader.java

Repository Revision Date User Message
ASF #745794 Thu Feb 19 09:47:15 UTC 2009 mikemccand LUCENE-1430 (on 2.4 branch): don't throw false AlreadyClosedException when IndexReader.open hits IOException on first try opening index
Files Changed
MODIFY /lucene/java/branches/lucene_2_4/CHANGES.txt
MODIFY /lucene/java/branches/lucene_2_4/src/java/org/apache/lucene/index/DirectoryIndexReader.java
MODIFY /lucene/java/branches/lucene_2_4
MODIFY /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestIndexReader.java