Mailing List Archive

Questions on index locking
Hey all,

I'm integrating the newest version of Lucene into our codebase, and ran
into a few questions about the directory locking. First, I'd like to
suggest that it might help to add some comments to the Javadocs of
IndexReader and IndexWriter about when directories are locked and what
it means. Second, is there a particular exception I can catch when
trying to open a directory to handle if a lock is already on that dir?
Would it make sense to add a DirectoryLockedException or something
similar?

Regards,
Matt


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
RE: Questions on index locking [ In reply to ]
> From: Matt Tucker [mailto:matt@jivesoftware.com]
>
> I'd like to
> suggest that it might help to add some comments to the Javadocs of
> IndexReader and IndexWriter about when directories are locked and what
> it means.

In short, an IndexWriter locks an index so that other IndexWriters cannot be
opened on the same index. This is the "write.lock" file. The IndexWriter
also locks the "commit.lock" file while it is installing a new version of
the index, and trying to delete files related to the old version. An
IndexReader also grabs the "commit.lock" while it is opening the index, so
that an IndexWriter doesn't try to delete files before it has a chance to
open all of them. (Now we just need to get this into the documentation...)

> Second, is there a particular exception I can catch when
> trying to open a directory to handle if a lock is already on that dir?
> Would it make sense to add a DirectoryLockedException or something
> similar?

Currently an IOException is thrown with a message indicating the problem.
Would your application be better served by a subclass of IOException?

Doug

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