lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From findbestopensource <findbestopensou...@gmail.com>
Subject Re: Concurrent Issue
Date Thu, 07 Apr 2011 06:08:23 GMT
You are trying to access the reader which is already closed by some other
thread.

1. Keep a reference count for the reader you create.
2. Have a common function through which all functions will retrieve Reader
objects
3. Once the index got changed, create a new reader, do warmup
4. When the new reader is ready then the common function should return this
for furture request and old reader should go in passive mode.
5. The old reader should be closed when the reference count is zero.

Regards
Aditya
www.findbestopensource.com


On Wed, Apr 6, 2011 at 7:20 PM, Piotr Pezik <piotr.pezik@gmail.com> wrote:

> Only to second this explanation.
>
> I got the same exception in a web application with a single IndexReader,
> accessed by many threads.
>
> The index gets updated every half hour or so, so I closed the old
> IndexReader and opened a new one every now and then.
>
> Even though the method for obtaining the IndexReader was synchronized, with
> tens of thousands of queries a day,
> I started getting the AlreadyClosed exception when one thread triggered the
> closure of the IndexReader which another thread was still using.
>
>
>
> Piotr
>
>
> On 5 Apr 2011, at 15:46, Ian Lea wrote:
>
> > You don't say exactly how you are dealing with the concurrent access
> > (one shared Reader/Searcher? Each user with own Reader/Searcher?
> > Something else?) but the underlying problem is that the reader has
> > been closed while something else is still using it.  This can easily
> > happen in a multi-threaded setup: thread A might close the reader
> > while thread B is still using it.
> >
> > Options include
> >
> > not closing the old reader straight away when open a new one, but
> > instead stash it somewhere and close it later when you can be
> > confident nothing else will be using it.
> >
> > using the SearcherManager class from Lucene In Action 2nd edition, or
> > an equivalent.
> >
> > catching the AlreadyClosed exception and restarting the search with a
> > current reader
> >
> >
> > --
> > Ian.
> >
> >
> > On Tue, Apr 5, 2011 at 12:56 PM, Yogesh Dabhi <ydabhi@asite.com> wrote:
> >> Hi
> >>
> >>
> >>
> >> My application is cluster in jobss application servers & lucene
> >> directory was shared.
> >>
> >>
> >>
> >> Concurrently 5 user access same lucene directory for searching document
> >>
> >> That time I got bellow exception
> >>
> >> org.apache.lucene.store.AlreadyClosedException: this IndexReader is
> >> closed
> >>
> >>
> >>
> >> is there a way to handle such error
> >>
> >>
> >>
> >> Thanks & Regards
> >>
> >> Yogesh
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message