lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: Stream Closed Exception and Lock Obtain Failed Exception while reading the file in chunks iteratively.
Date Mon, 02 Sep 2013 07:53:57 GMT
Hi,

LockObtainFailed is *always* caused by a missing close of the IndexWriter. The code is ununderstandable
and things like the evil Eclipse "automated-printStackTrace-catch-block" make it obvious that
the code is not designed correctly. To write good code, please *disable* this automatic feature
of Eclipse it is the source of *all* those errors. Declare all thrown Exceptions on the methods
and do the handling correctly without suppressing them on the level of opening/writing IndexWriter
using catch and finally blocks.

The cause of the OOM when not reopening IW can be caused by incorrect Exception handling,
too. In addition, instead of opening/closing IndexWriter you can call commit().

It would be good to see the code that writes to the index without reopening the reader all
the time, to find the root cause of your problem you are trying to workaround.

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: Ankit Murarka [mailto:ankit.murarka@rancoretech.com]
> Sent: Monday, September 02, 2013 8:57 AM
> To: java-user@lucene.apache.org
> Subject: Re: Stream Closed Exception and Lock Obtain Failed Exception while
> reading the file in chunks iteratively.
> 
> Hello..
> 
> I think you might be referring to the close method not present in catch
> method. if that's so, that is purposely done for the time being...
> 
> Else if the execution happens properly, then the flow won't go to catch as of
> now. Obviously the close will be present both in catch and finally block.
> 
> But I don't think this is possibly the root of this problem.
> 
> There seems to be another problem which is causing this issue..Would
> appreciate some guidance..
> 
> On 9/2/2013 12:11 PM, Trejkaz wrote:
> > On Mon, Sep 2, 2013 at 4:10 PM, Ankit Murarka
> > <ankit.murarka@rancoretech.com>  wrote:
> >
> >> There's a reason why Writer is being opened everytime inside a while
> >> loop. I usually open writer in main method itself as suggested by you
> >> and pass a reference to it. However what I have observed is that if
> >> my file contains more than 4 lakh lines, the writer.add(doc) line
> >> does not execute and throws an OutOfMemoryError although JVM is
> provided with enough heap.
> >>
> > The problem isn't opening it multiple times (although that does seem
> > unnecessary too), the problem is that half the time you're not closing
> > it.
> >
> > Try refactoring to always use the try(){} syntax so that all your
> > Closeable objects are being closed properly. You'll find all sorts of
> > issues with the code you posted.
> >
> > TX
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
> >
> 
> 
> --
> Regards
> 
> Ankit Murarka
> 
> "What lies behind us and what lies before us are tiny matters compared with
> what lies within us"
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message