Lock error attempting update of RAMDirectory index

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Lock error attempting update of RAMDirectory index

Philip Brown
I'm getting the following error trying to instantiate an IndexModifier on a RAMDirectory index:

java.io.IOException: Lock obtain timed out: org.apache.lucene.store.RAMDirectory$1@a336b7
        at org.apache.lucene.store.Lock.obtain(Lock.java(Compiled Code))
        at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:254)
        at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:244)
        at org.apache.lucene.index.IndexModifier.init(IndexModifier.java:148)
        at org.apache.lucene.index.IndexModifier.<init>(IndexModifier.java:111)
...

Here's some background:

I have a web application where, upon startup, this RAMDirectory is created and loaded with a set of values from 2 databases.  When a user makes a call to do a delete or add of data, it should update not only the database (obviously) but also the RAMDirectory index, such that the 2 are always in sync with one another.  

It was my thought to have a static class which calls an update method on itself every X number of minutes to recreate/reload the RAMDirectory index from the database -- this in addition to the simultaneous updates to RAMDirectory (removal of documents and adding of documents) and database to keep the data in sync.  Then, I should be able to just use searching capabilities that Lucene offers to get the data requested by the user, rather than issuing tons of select queries to the databases.  

What is causing this error, and how do I fix?  What would be a good approach for achieving the goal of database and index synchronization?

Thanks in advance,

Philip
Reply | Threaded
Open this post in threaded view
|

Re: Lock error attempting update of RAMDirectory index

Karl Wettin
On Thu, 2006-08-31 at 15:24 -0700, Philip Brown wrote:
>
> I'm getting the following error trying to instantiate an IndexModifier
> on a RAMDirectory index:
>
> java.io.IOException: Lock obtain timed out:
> org.apache.lucene.store.RAMDirectory$1@a336b7

You probably forgot to close an IndexWriter?


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Lock error attempting update of RAMDirectory index

Philip Brown
Well, I wish it were that easy...I open one IndexWriter to write the documents to the index after it is created, and then call writer.optimize() and writer.close().  Your suggestion is a good one in that, from what I've read, the writer needs to be closed to release the lock file.  Apparently, there is more to it than that.  Also, this doesn't happen consistently -- just occasionally.

Thanks.

karl wettin-3 wrote
On Thu, 2006-08-31 at 15:24 -0700, Philip Brown wrote:
>
> I'm getting the following error trying to instantiate an IndexModifier
> on a RAMDirectory index:
>
> java.io.IOException: Lock obtain timed out:
> org.apache.lucene.store.RAMDirectory$1@a336b7

You probably forgot to close an IndexWriter?


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Reply | Threaded
Open this post in threaded view
|

Re: Lock error attempting update of RAMDirectory index

Karl Wettin
On Thu, 2006-08-31 at 19:34 -0700, Philip Brown wrote:
karl wettin-3 wrote:

> >
> > On Thu, 2006-08-31 at 15:24 -0700, Philip Brown wrote:
> >>
> >> I'm getting the following error trying to instantiate an IndexModifier
> >> on a RAMDirectory index:
> >>
> >> java.io.IOException: Lock obtain timed out:
> >> org.apache.lucene.store.RAMDirectory$1@a336b7
> >
> > You probably forgot to close an IndexWriter?
>
> Well, I wish it were that easy...I open one IndexWriter to write the
> documents to the index after it is created, and then call writer.optimize()
> and writer.close().  Your suggestion is a good one in that, from what I've
> read, the writer needs to be closed to release the lock file.  Apparently,
> there is more to it than that.  Also, this doesn't happen consistently --
> just occasionally.

Set a breakpoint, print the stacktrace of a new instance of Exception to
your log, or do something similar in the lock methods of Lucene so you
will find out what code of yours lock and unlocks the index.

I'm quite convinced you forget to close something. Or perhaps you try to
modify at the same time as you insert documents.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Lock error attempting update of RAMDirectory index

Michael McCandless-2
>>> You probably forgot to close an IndexWriter?
>> Well, I wish it were that easy...I open one IndexWriter to write the
>> documents to the index after it is created, and then call writer.optimize()
>> and writer.close().  Your suggestion is a good one in that, from what I've
>> read, the writer needs to be closed to release the lock file.  Apparently,
>> there is more to it than that.  Also, this doesn't happen consistently --
>> just occasionally.
>
> Set a breakpoint, print the stacktrace of a new instance of Exception to
> your log, or do something similar in the lock methods of Lucene so you
> will find out what code of yours lock and unlocks the index.
>
> I'm quite convinced you forget to close something. Or perhaps you try to
> modify at the same time as you insert documents.

Why do you need an IndexWriter at all?  Can't you open a single
IndexModifier and use to do all adds/deletes against your RAMDirectory?
  Or maybe I'm not understanding the full context...

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]