You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Aad Nales <aa...@rotterdam-cs.com> on 2004/10/08 17:07:45 UTC
locking problems
Based on discussions in this group I figure that I should 'cache'
IndexSearchers and IndexReaders, which i did. I have build an
IndexSearcherPool and an IndexReaderPool. Both seem to work fine
(although I am still testing). However, whenever I use these I can not
create an IndexWriter. The thread fails and generates a timeout on
org.apache.lucene.store.Lock.obtain (1.3.1) in line 97.
Can somebody help me to figure out with what actions these locks are
obtained? I have been reading all faq's on the subject but failed to
understand the following:
1. can I have one or multiple searchers open when I open a writer?
2. can I have one or multiple readers open when I open a writer?
And if not. I am writing an application that does regular updates on the
index what kind of strategy could you advise? Should I use
ResourcePooling at all?
TIA,
Aad Nales
--
Aad Nales
aad.nales@rotterdam-cs.com, +31-(0)6 54 207 340
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: locking problems
Posted by Doug Cutting <cu...@apache.org>.
Aad Nales wrote:
> 1. can I have one or multiple searchers open when I open a writer?
> 2. can I have one or multiple readers open when I open a writer?
Yes, with one caveat: if you've called the IndexReader methods delete(),
undelete() or setNorm() then you may not open an IndexWriter until
you've closed that IndexReader instance.
In general, only a single object may modify an index at once, but many
may access it simultaneously in a read-only manner, including while it
is modified. Indexes are modified by either an IndexWriter or by the
IndexReader methods delete(), undelete() and setNorm().
Typically an application which modifies and searches simultaneously
should keep the following open:
1. A single IndexReader instance used for all searches, perhaps
opened via an IndexSearcher. Periodically, as the index changes, this
is discarded, and replaced with a new instance.
2. Either:
a. An IndexReader to delete documents.
b. An IndexWriter to add documents; or
So an updating thread might open (2a), delete old documents, close it,
then open (2b) add new documents, perhaps optimize, then close. At this
point, when the index has been updated (1) can be discarded and replaced
with a new instance. Typically the old instance of (1) is not
explicitly closed, rather the garbage collector closes it when the last
thread searching it completes.
Doug
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org