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 Harini Raghavan <ha...@insideview.com> on 2005/07/31 10:24:30 UTC

Re: IOException : Lock obtain timed out

The default value of IndexWriter.WRITE_LOCK_TIMEOUT property is 1000ms. Can 
this value be increased to some optimum value?

----- Original Message ----- 
From: "Harini Raghavan" <ha...@insideview.com>
To: <ja...@lucene.apache.org>
Sent: Saturday, July 30, 2005 11:23 PM
Subject: IOException : Lock obtain timed out


>
> Hi All,
>
> As mentioned in the mail below, I am adding documents to the Lucene index 
> based on JMS triggered events. I have made the method addDocument in the 
> LuceneActions class as 'synchronized'  as I was getting Index locked 
> exception. The problem was solved temporarily, but now I am getting a 
> different exception :  IOException : Lock obtain timed out.
> If I manually delete the lock file from the index directory, then it works 
> fine for a while and again throws the same exception.
> Below is the exception stack trace.
>
> java.io.IOException: Lock obtain timed out: 
> Lock@/var/tmp/lucene-9b05e175384cccd1f07bf2311a393c87-write.lock
>         at org.apache.lucene.store.Lock.obtain(Lock.java:58)
>         at 
> org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:223)
>         at 
> org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:173)
>         at lucene.LuceneActions.getIndexWriter(LuceneActions.java:160)
>         at lucene.LuceneActions.addDocument(LuceneActions.java:48)
>         at index.IndexServiceImpl.addData(IndexServiceImpl.java:63)
>         at index.IndexServiceImpl.addToIndex(IndexServiceImpl.java:28)
>         at 
> persistence.listener.DataEventsListenerImpl.consumeEvent(DataEventsListenerImpl.java:56)
>         at 
> persistence.listener.service.DataEventListenerBean.onMessage(DataEventListenerBean.java:34
>
> The LuceneActions.addDocument method is synchronized, so ideally till one 
> thread releases the lock and closes the index, the next thread will not 
> try to initialise a new IndexWriter. So I am wondering why this problem is 
> occuring. Can someone please help?
>
> Thanks,
> Harini
>
>> : Date: Mon, 18 Jul 2005 10:12:39 +0530
>> : From: Harini Raghavan <ha...@insideview.com>
>> : Reply-To: java-user@lucene.apache.org
>> : To: otis_gospodnetic@yahoo.com
>> : Cc: java-user@lucene.apache.org
>> : Subject: Re: Index locked exception while updating index
>> :
>> : Hi Otis,
>> :
>> : I tried to print the stack but there was no exception. I think I found 
>> the
>> : cause for the exception. The addDocument was being called by different
>> : threads simultaneously and so when a second thread was trying to access 
>> the
>> : index, it was already locked. So I made the method addDocument 
>> synchronized
>> : and that fixed the problem.
>> :
>> : Thanks for your quick response,
>> : Harini
>> :
>> :
>> : ----- Original Message -----
>> : From: "Otis Gospodnetic" <ot...@yahoo.com>
>> : To: <ja...@lucene.apache.org>
>> : Sent: Monday, July 18, 2005 10:03 AM
>> : Subject: Re: Index locked exception while updating index
>> :
>> :
>> : > Harini,
>> : >
>> : > You are catching IOException in the finally block, but you are not 
>> even
>> : > printing out the exception stack trace.  Perhaps you are not able to
>> : > close your IndexWriter for some reason.
>> : >
>> : > Otis
>> : >
>> : >
>> : > --- Harini Raghavan <ha...@insideview.com> wrote:
>> : >
>> : >> Hi All,
>> : >> I am quite new to Lucene and I have problem with locking. I have a
>> : >> MessageDrivenBean that sends messages to my Lucene indexer whenever
>> : >> there is
>> : >> a  new database update. The indexer updates the index incrementally 
>> .
>> : >> Below
>> : >> is the code fragment in the indexer method that gets invoked by the
>> : >> MDB
>> : >> listener.
>> : >>
>> : >>  public void addDocument(Document doc) {
>> : >>      String indexLoc = luceneConfig.getIndexDir();
>> : >>      IndexWriter writer = getIndexWriter(indexLoc, false);
>> : >>      try{
>> : >>           writer.addDocument(doc);
>> : >>      } catch(IOException e) {
>> : >>             logger.error("IOException occurred in addDocument()");
>> : >>      } catch(Exception e) {
>> : >>             logger.error("Exception occurred in addDocument()");
>> : >>      } finally {
>> : >>             try {
>> : >>                 writer.close();
>> : >>            } catch(IOException e){
>> : >>     }
>> : >> }
>> : >>
>> : >> The incremental update works fine twice and the third time it throws
>> : >> the
>> : >> following exception :
>> : >>
>> : >> java.io.IOException: Index locked for write:
>> : >> Lock@C:\tmpIndex\write.lock
>> : >> at org.apache.lucene.index.IndexWriter.<init>(Unknown Source)
>> : >> at org.apache.lucene.index.IndexWriter.<init>(Unknown Source)
>> : >> at lucene.LuceneActions.getIndexWriter(LuceneActions.java:151)
>> : >> at lucene.LuceneActions.addDocument(LuceneActions.java:43)
>> : >> at index.IndexServiceImpl.addData(IndexServiceImpl.java:63)
>> : >> at index.IndexServiceImpl.addToIndex(IndexServiceImpl.java:28)
>> : >>
>> : >> The Index Writer is created every time and also closed in the 
>> finally
>> : >> block.
>> : >> Should I be doing something else?
>> : >> Any help would be appreciated.
>> : >> Thanks,
>> : >> Harini
>> : >>
>> : >>
>> : 
>>  >> ---------------------------------------------------------------------
>> : >> 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
>> : >
>> :
>> :
>> : ---------------------------------------------------------------------
>> : To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> : For additional commands, e-mail: java-user-help@lucene.apache.org
>> :
>>
>>
>>
>> -Hoss
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 


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