RE: LockObtainFailedException

View: New views
3 Messages — Rating Filter:   Alert me  

RE: LockObtainFailedException

by Chris Bamford-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Anshum,

Yes there is a reply, but it is Solr specific :-)
I understand that I can catch the exception, but then what can I do about it when it occurs?  In my case I am pretty sure that the 'write.lock' file is stale - most probably left from the last time Tomcat shut down - so I want to force it to be opened.  How can I do that?  Am I obliged to locate the file and remove it myself before attempting to repeat the open() - or is there something in the API to help?

Thanks

- Chris

----- Original Message -----
From: Anshum <anshumg@...>
Sent: Mon, 11/2/2009 10:08am
To: java-user@...
Subject: Re: LockObtainFailedException

Hi Chris,

Isn't there a reply @ the older thread?
In case there isn't, this is generally observed when an indexwriter is not
closed properly i.e. just not closed.
The lock is created on opening the indexwriter to maintain the sanity of the
index. This lock gets removed on closing writer.close(). In case of
exceptions, when the indexwriter.close() is not closed, the subsequent call
to an index operation (opening a writer) would result in a
lockobtainfailedexception.
Try using a finally block to handle such cases.

--
Anshum Gupta
Naukri Labs!
http://ai-cafe.blogspot.com

The facts expressed here belong to everybody, the opinions to me. The
distinction is yours to draw............


On Mon, Nov 2, 2009 at 3:27 PM, Chris Bamford <Chris.Bamford@...>wrote:

> Hi,
>
> I was researching LockObtainFailedExceptions and came across this thread.
> I
> don't use Solr, just regular Lucene deployed via Tomcat - but I have
> started getting these exceptions which coincides with our recent
> upgrade from 2.0.0 to 2.4.0.
> I have found that just removing the lock file
> seems to clear up the problem, but I was hoping for (a) a better
> understanding of why they might occur in the first place and (b) some
> thoughts on how I might deal with them programatically.
>
> Thanks for any ideas / pointers,
>
> - Chris
>

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


Re: LockObtainFailedException

by Anshum-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is that a part of some regular process? as in the tomcat shutdown? if it is,
could you pass a shutdown signal to the search daemon/service and then get
it to close the already opened writers.
Also if its the service that causes the exception, add a writer.close
statement to the finally block (add that if that's not already in place).
That should solve the problem.

--
Anshum Gupta
Naukri Labs!
http://ai-cafe.blogspot.com

The facts expressed here belong to everybody, the opinions to me. The
distinction is yours to draw............


On Mon, Nov 2, 2009 at 3:50 PM, Chris Bamford <Chris.Bamford@...>wrote:

> Hi Anshum,
>
> Yes there is a reply, but it is Solr specific :-)
> I understand that I can catch the exception, but then what can I do about
> it when it occurs?  In my case I am pretty sure that the 'write.lock' file
> is stale - most probably left from the last time Tomcat shut down - so I
> want to force it to be opened.  How can I do that?  Am I obliged to locate
> the file and remove it myself before attempting to repeat the open() - or is
> there something in the API to help?
>
> Thanks
>
> - Chris
>
> ----- Original Message -----
> From: Anshum <anshumg@...>
> Sent: Mon, 11/2/2009 10:08am
> To: java-user@...
> Subject: Re: LockObtainFailedException
>
> Hi Chris,
>
> Isn't there a reply @ the older thread?
> In case there isn't, this is generally observed when an indexwriter is not
> closed properly i.e. just not closed.
> The lock is created on opening the indexwriter to maintain the sanity of
> the
> index. This lock gets removed on closing writer.close(). In case of
> exceptions, when the indexwriter.close() is not closed, the subsequent call
> to an index operation (opening a writer) would result in a
> lockobtainfailedexception.
> Try using a finally block to handle such cases.
>
> --
> Anshum Gupta
> Naukri Labs!
> http://ai-cafe.blogspot.com
>
> The facts expressed here belong to everybody, the opinions to me. The
> distinction is yours to draw............
>
>
> On Mon, Nov 2, 2009 at 3:27 PM, Chris Bamford <Chris.Bamford@...
> >wrote:
>
> > Hi,
> >
> > I was researching LockObtainFailedExceptions and came across this thread.
> > I
> > don't use Solr, just regular Lucene deployed via Tomcat - but I have
> > started getting these exceptions which coincides with our recent
> > upgrade from 2.0.0 to 2.4.0.
> > I have found that just removing the lock file
> > seems to clear up the problem, but I was hoping for (a) a better
> > understanding of why they might occur in the first place and (b) some
> > thoughts on how I might deal with them programatically.
> >
> > Thanks for any ideas / pointers,
> >
> > - Chris
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@...
> For additional commands, e-mail: java-user-help@...
>
>

Re: LockObtainFailedException

by Michael McCandless-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It's best to arrange w/ Tomcat's shutdown to close any open writers.

But, you can also use IndexWriter.unlock(Directory) to forcefully
remove the lock.  But be very careful: if you accidentally remove a
lock out from under a live IndexWriter, that will quickly lead to
index corruption.

Mike

On Mon, Nov 2, 2009 at 5:20 AM, Chris Bamford <Chris.Bamford@...> wrote:

> Hi Anshum,
>
> Yes there is a reply, but it is Solr specific :-)
> I understand that I can catch the exception, but then what can I do about it when it occurs?  In my case I am pretty sure that the 'write.lock' file is stale - most probably left from the last time Tomcat shut down - so I want to force it to be opened.  How can I do that?  Am I obliged to locate the file and remove it myself before attempting to repeat the open() - or is there something in the API to help?
>
> Thanks
>
> - Chris
>
> ----- Original Message -----
> From: Anshum <anshumg@...>
> Sent: Mon, 11/2/2009 10:08am
> To: java-user@...
> Subject: Re: LockObtainFailedException
>
> Hi Chris,
>
> Isn't there a reply @ the older thread?
> In case there isn't, this is generally observed when an indexwriter is not
> closed properly i.e. just not closed.
> The lock is created on opening the indexwriter to maintain the sanity of the
> index. This lock gets removed on closing writer.close(). In case of
> exceptions, when the indexwriter.close() is not closed, the subsequent call
> to an index operation (opening a writer) would result in a
> lockobtainfailedexception.
> Try using a finally block to handle such cases.
>
> --
> Anshum Gupta
> Naukri Labs!
> http://ai-cafe.blogspot.com
>
> The facts expressed here belong to everybody, the opinions to me. The
> distinction is yours to draw............
>
>
> On Mon, Nov 2, 2009 at 3:27 PM, Chris Bamford <Chris.Bamford@...>wrote:
>
>> Hi,
>>
>> I was researching LockObtainFailedExceptions and came across this thread.
>> I
>> don't use Solr, just regular Lucene deployed via Tomcat - but I have
>> started getting these exceptions which coincides with our recent
>> upgrade from 2.0.0 to 2.4.0.
>> I have found that just removing the lock file
>> seems to clear up the problem, but I was hoping for (a) a better
>> understanding of why they might occur in the first place and (b) some
>> thoughts on how I might deal with them programatically.
>>
>> Thanks for any ideas / pointers,
>>
>> - Chris
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@...
> For additional commands, e-mail: java-user-help@...
>
>

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