lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabe <gj...@yahoo.com>
Subject RE: java.io.IOException: Lock obtain timed out
Date Mon, 15 Mar 2004 19:46:25 GMT

I notice in your "catch" clause you always set the
writer to be true... (i.e. new IndexWriter(INDEX_DIR,
analyzer, true). 

If I am not mistaken reading the docs, this overwrites
the entire index, no? That is why I was setting that
variable to false when doing an incremental update.
When I reindex all documents, I have had no problem.

Gabe

--- "Nguyen, Tri (NIH/NLM/LHC)"
<nguyent@ceb.nlm.nih.gov> wrote:
> Did you close your writer if an Exception occured?
> 
> I had a similiar problem, but it was fixed when i
> close the writer in the
> finally block.
> 
> Below is my original code (which generate
> Mjava.io.Exception: Lock obtain
> timed out when an Exception is thrown)
> 
> public static void index(File indexDir, List cList,
> boolean ow) 
> throws Exception{
>     IndexWriter writer = null;
>     try{  
>         writer = new IndexWriter(indexDir, new
> MyAnalyzer(), overwrite); 
>     	  // index documents
>     }
>     catch(Exception e){
> 	  writer = new IndexWriter(indexDir, new
> MyAnalyzer(), true);
>         try{    	  
>             // index documents 
>         }
>         catch(Exception ee){ 
>             throw ee;  
>         }
>     }
>     writer.close();  // never reaches this statement
> if the catch block is
> called.  
> }
> 
> 
> // revised code to force a close on the IndexWriter
> public static void index(File indexDir, List cList,
> boolean ow) 
> throws Exception{
>     IndexWriter writer = null;
>     try{  
>         writer = new IndexWriter(indexDir, new
> MyAnalyzer(), overwrite); 
>     	  // index documents
>         writer.close();
>     }
>     catch(Exception e){
> 	  writer = new IndexWriter(indexDir, new
> MyAnalyzer(), true);
>         try{    	  
>             // index documents 
>         }
>         catch(Exception ee){ 
>             throw ee;  
>         }
>         finally{ 
>             writer.close(); 
>         } 
>     }
> }
> 
> 
> 
> -----Original Message-----
> 
> 
> From: Gabe [mailto:gjz22@yahoo.com] 
> Sent: Monday, March 15, 2004 1:53 PM
> To: Lucene Users List
> Subject: Re: java.io.IOException: Lock obtain timed
> out
> 
> 
> Otis,
> 
> I only put the unlock call in because I had the
> error
> in the first place. Removing it, the IOException
> still
> occurs, when trying to instantiate the IndexWriter.
> 
> Thanks,
> Gabe
> 
> --- Otis Gospodnetic <otis_gospodnetic@yahoo.com>
> wrote:
> > There is no need for that .unlock call, just
> > .close()
> > 
> > Otis
> > 
> > --- Gabe <gjz22@yahoo.com> wrote:
> > > 
> > > I am using Lucene 1.3 final and am having an
> error
> > > that I can't seem to shake. Basically, I am
> > updating a
> > > Document in the index incrementally by calling
> an
> > > IndexReader to remove the document. This works.
> > Then,
> > > I close the IndexReader with the following code:
> > > 
> > > reader.unlock(reader.directory());
> > > reader.close();
> > > 
> > > I put the first of the two lines in to try to
> > force
> > > the lock to disable. According to the logging,
> > this
> > > code is being called and the IndexReader is
> being
> > > closed.
> > > 
> > > However, then I open a writer to add the
> document,
> > I
> > > get the following.
> > > 
> > > java.io.IOException: Lock obtain timed out
> > >         at
> > >
> org.apache.lucene.store.Lock.obtain(Lock.java:97)
> > >         at
> > >
> >
>
org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:173)
> > >         at 
> > > 
> > > ...
> > > 
> > > I open the writer by calling:
> > > return new IndexWriter(INDEX_DIR, analyzer,
> > false);
> > > 
> > > where analyzer=new StandardAnalyzer();
> > > 
> > > I get the reader by calling:
> > > IndexReader reader=IndexReader.open(INDEX_DIR);
> > > 
> > > Thanks for any help,
> > > Gabe
> > > 
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! Mail - More reliable, more storage, less
> > spam
> > > http://mail.yahoo.com
> > > 
> > >
> >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > lucene-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> > lucene-user-help@jakarta.apache.org
> > > 
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > lucene-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > lucene-user-help@jakarta.apache.org
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - More reliable, more storage, less spam
> http://mail.yahoo.com
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> lucene-user-help@jakarta.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> lucene-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com

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


Mime
View raw message