lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: NRTManager and AlreadyClosedException
Date Wed, 08 Feb 2012 12:21:20 GMT
Releasing a searcher is not the same as closing the searcher manager,
if that is what you mean.

The searcher should indeed be released, but once only for each
acquire().  Your searching threads should have code like that shown in
the SearcherManager javadocs.

IndexSearcher s = manager.acquire();
 try {
   // Do searching, doc retrieval, etc. with s
 } finally {
   manager.release(s);
 }
 // Do not use s after this!
 s = null;

--
Ian.


On Wed, Feb 8, 2012 at 12:09 PM, Cheng <zhoucheng2008@gmail.com> wrote:
> You are right. There is a method by which I do searching. At the end of the
> method, I release the index searcher (not the searchermanager).
>
> Since this method is called by multiple threads. So I think the index
> searcher will be released multiple times.
>
> First, I wonder if releasing searcher is same as releasing the searcher
> manager.
>
> Second, as said in Mike's blog, the searcher should be released, which has
> seemingly caused the problem. What are my alternatives here to avoid it?
>
> Thanks
>
>
>
> On Wed, Feb 8, 2012 at 7:51 PM, Ian Lea <ian.lea@gmail.com> wrote:
>
>> Are you closing the SearcherManager?  Calling release() multiple times?
>>
>> From the exception message the first sounds most likely.
>>
>>
>> --
>> Ian.
>>
>>
>> On Wed, Feb 8, 2012 at 5:20 AM, Cheng <zhoucheng2008@gmail.com> wrote:
>> > Hi,
>> >
>> > I am using NRTManager and NRTManagerReopenThread. Though I don't close
>> > either writer or the reopen thread, I receive AlreadyClosedException as
>> > follow.
>> >
>> > My initiating NRTManager and NRTManagerReopenThread are:
>> >
>> > FSDirectory indexDir = new NIOFSDirectory(new File(
>> > indexFolder));
>> >
>> > IndexWriterConfig iwConfig = new IndexWriterConfig(
>> > version, new LimitTokenCountAnalyzer(
>> > StandardAnalyzer, maxTokenNum));
>> >
>> > iw = new IndexWriter(indexDir, iwConfig);
>> >
>> > nrtm = new NRTManager(iw, null);
>> >
>> > ropt = new NRTManagerReopenThread(nrtm,
>> > targetMaxStaleSec,
>> > targetMinStaleSec);
>> >
>> > ropt.setName("Reopen Thread");
>> > ropt.setPriority(Math.min(Thread.currentThread().getPriority() + 2,
>> > Thread.MAX_PRIORITY));
>> > ropt.setDaemon(true);
>> > ropt.start();
>> >
>> >
>> > Where may the searchermanager fall out?
>> >
>> >
>> >
>> > org.apache.lucene.store.AlreadyClosedException: this SearcherManager is
>> > closed77
>> > at
>> >
>> org.apache.lucene.search.SearcherManager.acquire(SearcherManager.java:235)
>> > at
>> com.yyt.core.er.lucene.YYTLuceneImpl.codeIndexed(YYTLuceneImpl.java:138)
>> > at com.yyt.core.er.main.copy.SingleCodeER.run(SingleCodeER.java:50)
>> > at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>> > at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>

---------------------------------------------------------------------
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