I think I see how this exception can happen. I think you are hitting
a different exception, which is masked by the exception you're seeing.
Can you run CheckIndex on this index? I think that should show the
actual root cause.
I think another simple way to see the root cause would be to
separately first open the directory:
Directory dir = FSDirectory.getDirectory("/path/to/index");
And then instantiate your IndexSearcher with that dir.
Is there only 1 segment in the index?
I see a path whereby on opening a SegmentReader (ie there's only a
single segment), on then hitting an exception we call doClose() on the
SegmentReader, which will close the directory, but then the retry
logic (trying different segments_N files) kicks in which then hits the
AlreadyClosedException. It's a bug we should fix (I'll open it & fix
it).
Mike
Mindaugas Žakšauskas wrote:
Hi Erick,
Sorry for not providing the context. The problem is that I couldn't
work out the exact test case for causing this - I will definitely post
one if I find. There's a possible cause for this but I don't want to
speculate as I don't know for sure.
Just to answer (some of) your questions, this error has nothing to do
with migration, closing, etc. and this only occurred on v2.4.0. As you
can probably see from the stack trace, I'm simply opening an
IndexSearcher. If anyone's interested, I can post compressed folder
with index files (3Mb uncompressed) which are causing trouble.
Currently, a very basic test on this folder fails with the same
exception:
8<-------------------------------
import org.apache.lucene.search.IndexSearcher;
public class Test {
public static void main( String[] args ) throws Exception {
new IndexSearcher(
"/home/mindas/temp/luke/collection_32/checkedout_index" );
}
}
8<-------------------------------
My point of this post was - should the constructor ever throw this
exception? Can this not be gracefully swallowed and handled inside?
Regards,
Mindaugas
On Wed, Oct 29, 2008 at 12:51 PM, Erick Erickson
<[EMAIL PROTECTED]> wrote:
Well, I'd expect it to throw this error if you tried to close
an already-closed FSDirectory, But that's pretty useless since
you don't provide much context around your problem.
Did this just start occurring? Did you just migrate to 2.4 from
a previous version? Are you sure you aren't closing an already-
closed FSDir? What was the last thing you changed before
you saw this behavior? Did it ever work?
Best
Erick
On Wed, Oct 29, 2008 at 8:42 AM, Mindaugas Žakšauskas <[EMAIL PROTECTED]
>wrote:
Hi,
We're using Lucene 2.4.0 on Linux. Java version is 1.6.0_06.
Is there any reason why Lucene would be throwing this error:
org.apache.lucene.store.AlreadyClosedException: this Directory is
closed
at
org.apache.lucene.store.Directory.ensureOpen(Directory.java:220)
at
org.apache.lucene.store.FSDirectory.fileExists(FSDirectory.java:326)
at
org.apache.lucene.index.SegmentInfos
$FindSegmentsFile.run(SegmentInfos.java:680)
at
org
.apache
.lucene.index.DirectoryIndexReader.open(DirectoryIndexReader.java:
111)
at org.apache.lucene.index.IndexReader.open(IndexReader.java:
316)
at org.apache.lucene.index.IndexReader.open(IndexReader.java:
206)
at
org.apache.lucene.search.IndexSearcher.<init>(IndexSearcher.java:47)
<..our own code which calls new IndexSearcher( String ) ..>
If the index would be corrupted I'd expect
org.apache.lucene.index.CorruptIndexException; similar for
java.io.IOException, however this is something different.
Obviously, AlreadyClosedException is a runtime exception and doesn't
have to be declared in constructor javadoc, however, the problem
is a
bit scary as it leaves me in a position with no choice.
Thanks is advance.
Regards,
Mindaugas
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]