Re: Concurrent read and write

2005-01-23 Thread Cheolgoo Kang
Lucene's write lock is simple. There are four places that requires the
write lock.
Those are IndexReader.delete(int), IndexReader.setNorm(int,String,byte),
IndexReader.undeleteAll(), and IndexWriter.. Once you've used
one of methods
above, you should close that IndexReader or IndexWriter instance to
release the write
lock (and to avoid the Lock-obtain-timed-out exception).

For example, the following sequence should be okay.
> IndexReader reader = IndexReader.open( DIR );
> reader.delete( new Term( "A", "B" ) );
> reader.close();
> IndexWriter writer = new IndexWriter( DIR, a, b );
> writer.add( oneDocument );
> writer.close();

But, a sequence following causes a "Lock obtain timed out" exception.
> IndexReader reader = IndexReader.open( DIR );
> reader.delete( new Term( "A", "B" ) );
> IndexWriter writer = new IndexWriter( DIR, a, b );

Because, the write lock obtained at IndexReader.delete() wouldn't be removed
by IndexReader.close() and "new IndexWriter()" sentence requires a write lock.


On Fri, 21 Jan 2005 08:20:12 -0800 (PST), Otis Gospodnetic
<[EMAIL PROTECTED]> wrote:
> Hello Ashley,
> 
> You can read/search while modifying the index, but you have to ensure
> only one thread or only one process is modifying an index at any given
> time.  Both IndexReader and IndexWriter can be used to modify an index.
>  The former to delete Documents and the latter to add them.  You have
> to ensure these two operations don't overlap.
> c.f. http://www.lucenebook.com/search?query=concurrent
> 
> Otis
> 
> 
> --- Ashley Steigerwalt <[EMAIL PROTECTED]> wrote:
> 
> > I am a little fuzzy on the thread-safeness of Lucene, or maybe just
> > java.
> > From what I understand, and correct me if I'm wrong, Lucene takes
> > care of
> > concurrency issues and it is ok to run a query while writing to an
> > index.
> >
> > My question is, does this still hold true if the reader and writer
> > are being
> > executed as separate programs?  I have a cron job that will update
> > the index
> > periodically.  I also have a search application on a web form.  Is
> > this going
> > to cause trouble if someone runs a query while the indexer is
> > updating?
> >
> > Ashley
> >
> > -
> > 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]
> 
> 


-- 
Cheolgoo, Kang

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Concurrent read and write

2005-01-21 Thread Otis Gospodnetic
Hello Ashley,

You can read/search while modifying the index, but you have to ensure
only one thread or only one process is modifying an index at any given
time.  Both IndexReader and IndexWriter can be used to modify an index.
 The former to delete Documents and the latter to add them.  You have
to ensure these two operations don't overlap.
c.f. http://www.lucenebook.com/search?query=concurrent

Otis


--- Ashley Steigerwalt <[EMAIL PROTECTED]> wrote:

> I am a little fuzzy on the thread-safeness of Lucene, or maybe just
> java.  
> From what I understand, and correct me if I'm wrong, Lucene takes
> care of 
> concurrency issues and it is ok to run a query while writing to an
> index.
> 
> My question is, does this still hold true if the reader and writer
> are being 
> executed as separate programs?  I have a cron job that will update
> the index 
> periodically.  I also have a search application on a web form.  Is
> this going 
> to cause trouble if someone runs a query while the indexer is
> updating?
> 
> Ashley
> 
> -
> 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]



Re: Concurrent read and write

2005-01-21 Thread Clas Rydergren
Hi,

My limited experience shows that reading/searching in a servlet at the
"same" time as writing to the index from an application (e.g. by a
scheduled script) works very well.

The only thing that has caused me problems is applications (e.g. cron
started) writing to the index that "crash" while the write-lock is in
effect. (The "crash" is in my case often cause by bad socket
programming, and has nothing to do with Lucene.) The following
scheduled applications will then, of cause, not be able to update the
index.

cheers
Clas / frisim.com


On Fri, 21 Jan 2005 09:57:22 -0500, Ashley Steigerwalt
<[EMAIL PROTECTED]> wrote:
> I am a little fuzzy on the thread-safeness of Lucene, or maybe just java.
> From what I understand, and correct me if I'm wrong, Lucene takes care of
> concurrency issues and it is ok to run a query while writing to an index.
> 
> My question is, does this still hold true if the reader and writer are being
> executed as separate programs?  I have a cron job that will update the index
> periodically.  I also have a search application on a web form.  Is this going
> to cause trouble if someone runs a query while the indexer is updating?
> 
> Ashley
> 
> -
> 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]