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 Claes Holmerson <cl...@polopoly.com> on 2004/08/25 08:24:53 UTC

Lock handling

Hello,

I am interested to hear how people handle locked indexes, for example 
when catching an IOException like below.

java.io.IOException: Lock obtain timed out:
Lock@/tmp/lucene-0b978f2c0aa12e8dcdbd5b0df491bfc4-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:213)

As far as I can tell, there is no good way to tell whether the lock is 
only temporary (working as it should), or if it was created by a process 
that later died, and therefore can not remove it. How can I detect the 
latter case, and how should I best handle it?

Thanks,
Claes


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


Re: Lock handling

Posted by Otis Gospodnetic <ot...@yahoo.com>.
My suggestion was referring to a timestamp that could be obtained via
java.io.File, not something provided by Lucene.

Otis

--- Claes Holmerson <cl...@polopoly.com> wrote:

> Yes, looking at the time of the lock was an idea I had but I could
> not
> find anything like a time stamp. Am I missing something obvious here?
> 
> Claes
> 
> Otis Gospodnetic wrote:
> 
> >Hello,
> >
> >If you use Lucene incorrectly (e.g. 2 IndexWriters writing to the
> same
> >index), you will see this error.  Lucene has no way of telling
> whether
> >the lock file was left over from a previous process, or whether it's
> a
> >valid lock file because another process is currently indexing
> documents
> >or some such.
> >You could try adding some logic to your app, though.  For instance,
> you
> >can look at lock's timestamp, and using IndexReader.unlock(...)
> method
> >to forcefully unlock the index.
> >
> >Otis
> >
> >--- Claes Holmerson <cl...@polopoly.com> wrote:
> >
> >  
> >
> >>Hello,
> >>
> >>I am interested to hear how people handle locked indexes, for
> example
> >>
> >>when catching an IOException like below.
> >>
> >>java.io.IOException: Lock obtain timed out:
> >>Lock@/tmp/lucene-0b978f2c0aa12e8dcdbd5b0df491bfc4-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:213)
> >>
> >>As far as I can tell, there is no good way to tell whether the lock
> >>is 
> >>only temporary (working as it should), or if it was created by a
> >>process 
> >>that later died, and therefore can not remove it. How can I detect
> >>the 
> >>latter case, and how should I best handle it?
> >>
> >>Thanks,
> >>Claes
> >>
> >>
>
>>---------------------------------------------------------------------
> >>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
> >
> >
> >  
> >
> 
> -- 
> Claes Holmerson
> Polopoly - Cultivating the information garden
> Kungsgatan 88, SE-112 27 Stockholm, SWEDEN
> Direct: +46 8 506 782 59
> Mobile: +46 704 47 82 59
> Fax:  +46 8 506 782 51
> claes.holmerson@polopoly.com, http://www.polopoly.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


Re: Lock handling

Posted by Claes Holmerson <cl...@polopoly.com>.
Yes, looking at the time of the lock was an idea I had but I could not
find anything like a time stamp. Am I missing something obvious here?

Claes

Otis Gospodnetic wrote:

>Hello,
>
>If you use Lucene incorrectly (e.g. 2 IndexWriters writing to the same
>index), you will see this error.  Lucene has no way of telling whether
>the lock file was left over from a previous process, or whether it's a
>valid lock file because another process is currently indexing documents
>or some such.
>You could try adding some logic to your app, though.  For instance, you
>can look at lock's timestamp, and using IndexReader.unlock(...) method
>to forcefully unlock the index.
>
>Otis
>
>--- Claes Holmerson <cl...@polopoly.com> wrote:
>
>  
>
>>Hello,
>>
>>I am interested to hear how people handle locked indexes, for example
>>
>>when catching an IOException like below.
>>
>>java.io.IOException: Lock obtain timed out:
>>Lock@/tmp/lucene-0b978f2c0aa12e8dcdbd5b0df491bfc4-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:213)
>>
>>As far as I can tell, there is no good way to tell whether the lock
>>is 
>>only temporary (working as it should), or if it was created by a
>>process 
>>that later died, and therefore can not remove it. How can I detect
>>the 
>>latter case, and how should I best handle it?
>>
>>Thanks,
>>Claes
>>
>>
>>---------------------------------------------------------------------
>>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
>
>
>  
>

-- 
Claes Holmerson
Polopoly - Cultivating the information garden
Kungsgatan 88, SE-112 27 Stockholm, SWEDEN
Direct: +46 8 506 782 59
Mobile: +46 704 47 82 59
Fax:  +46 8 506 782 51
claes.holmerson@polopoly.com, http://www.polopoly.com



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


Re: Lock handling

Posted by Otis Gospodnetic <ot...@yahoo.com>.
Hello,

If you use Lucene incorrectly (e.g. 2 IndexWriters writing to the same
index), you will see this error.  Lucene has no way of telling whether
the lock file was left over from a previous process, or whether it's a
valid lock file because another process is currently indexing documents
or some such.
You could try adding some logic to your app, though.  For instance, you
can look at lock's timestamp, and using IndexReader.unlock(...) method
to forcefully unlock the index.

Otis

--- Claes Holmerson <cl...@polopoly.com> wrote:

> Hello,
> 
> I am interested to hear how people handle locked indexes, for example
> 
> when catching an IOException like below.
> 
> java.io.IOException: Lock obtain timed out:
> Lock@/tmp/lucene-0b978f2c0aa12e8dcdbd5b0df491bfc4-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:213)
> 
> As far as I can tell, there is no good way to tell whether the lock
> is 
> only temporary (working as it should), or if it was created by a
> process 
> that later died, and therefore can not remove it. How can I detect
> the 
> latter case, and how should I best handle it?
> 
> Thanks,
> Claes
> 
> 
> ---------------------------------------------------------------------
> 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