lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grzegorz TaƄczyk <golia...@polzone.pl>
Subject NIOFSDirectory and Thread.interrupt
Date Sun, 16 Oct 2011 10:32:46 GMT
Hello,

I had some problem with this issue:
https://issues.apache.org/jira/browse/LUCENE-2239

I was getting ClosedByInterruptException even though my application was 
not calling Thread.interrupt() anywhere.

There were 2 scenarios of getting this exception:

class MyThread extends Thread {
    public void run() {
      // ...
        update();
    }
    private void update() {
         // some loop
             otherclass.getIndexWriter().addDocument(doc);
       otherclass.getIndexWriter().commit(); // <- 
ClosedByInterruptException here
    }
}

java.nio.channels.ClosedByInterruptException
         at 
java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:184)
         at sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:630)
         at 
org.apache.lucene.store.NIOFSDirectory$NIOFSIndexInput.readInternal(NIOFSDirectory.java:161)
         at 
org.apache.lucene.store.BufferedIndexInput.readBytes(BufferedIndexInput.java:139)
         at 
org.apache.lucene.index.CompoundFileReader$CSIndexInput.readInternal(CompoundFileReader.java:272)
         at 
org.apache.lucene.store.BufferedIndexInput.refill(BufferedIndexInput.java:213)
         at 
org.apache.lucene.store.BufferedIndexInput.readByte(BufferedIndexInput.java:39)
         at org.apache.lucene.store.DataInput.readVInt(DataInput.java:105)
         at 
org.apache.lucene.store.BufferedIndexInput.readVInt(BufferedIndexInput.java:181)
         at org.apache.lucene.index.TermBuffer.read(TermBuffer.java:64)
         at 
org.apache.lucene.index.SegmentTermEnum.next(SegmentTermEnum.java:131)
         at 
org.apache.lucene.index.SegmentTermEnum.scanTo(SegmentTermEnum.java:166)
         at 
org.apache.lucene.index.TermInfosReader.get(TermInfosReader.java:273)
         at 
org.apache.lucene.index.TermInfosReader.get(TermInfosReader.java:209)
         at 
org.apache.lucene.index.SegmentTermDocs.seek(SegmentTermDocs.java:57)
         at 
org.apache.lucene.index.BufferedDeletesStream.applyTermDeletes(BufferedDeletesStream.java:351)
         at 
org.apache.lucene.index.BufferedDeletesStream.applyDeletes(BufferedDeletesStream.java:253)
         at 
org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:3571)
         at org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:3508)
         at 
org.apache.lucene.index.IndexWriter.prepareCommit(IndexWriter.java:3371)
         at 
org.apache.lucene.index.IndexWriter.commitInternal(IndexWriter.java:3444)
         at 
org.apache.lucene.index.IndexWriter.commit(IndexWriter.java:3426)
         at 
org.apache.lucene.index.IndexWriter.commit(IndexWriter.java:3410)
         at MyThread.update(MyThread.java:182)
         at MyThread.run(MyThread.java:42)



First try to find some workarund was by moving IndexWriter.commit call 
somewhere before last line and it worked, ClosedByInterruptException was 
not thrown anymore, however ClosedChannelException was thrown in other 
thread when using IndexSearcher(NRT) after mythread ended 
normally(without interrupt). I also tried to put some Thread.sleep() on 
end of run(), but still it didn't help.
Finally i solved the problem by making mythread reusable. This is not 
perfect solution for me, but for now it's working.

On note which may be important: MyThread is loaded using URLClassLoader

Conclusion is that you can't access NIOFSDirectory in thread which will 
end normally or by interrupt. It happened in 3.3.0.

Thanks

--
Regards




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


Mime
View raw message