lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael McCandless (JIRA)" <>
Subject [jira] Commented: (LUCENE-748) Exception during IndexWriter.close() prevents release of the write.lock
Date Mon, 18 Dec 2006 17:54:22 GMT
    [ ] 
Michael McCandless commented on LUCENE-748:

I think this (not releasing write lock on hitting an exception) is
actually by design.  It's because the writer still has pending changes
to commit to disk.

And, with the fix for LUCENE-702 (just committed), if we hit an
exception during IndexWriter.close(), the IndexWriter is left in a
consistent state (this is not quite the case pre-2.1).

Meaning, if you caught that exception, fixed the root cause (say freed
up disk space), and called close again (successfully), you would not
have lost any documents, and the write lock will be released.

I can also see that if we did release the write lock on exception,
this could dangerously / easily mask the fact that there was an
exception.  Ie, if the IOException is caught and ignored (or writes a
message but nobody sees it), and the write lock was released, then you
could go for quite a while before discovering eg that new docs weren't
visible in the index.  Whereas, keeping the write lock held on
exception will cause much faster discovery of the problem (eg when the
next writer tries to instantiate).

I think this is the right exception semantics to aim for?  Ie if the
close did not succeed we should not release the write lock (because we
still have pending changes).

Then, if you want to force releasing of the write lock, you can still
do something like this:

  try {
  } finally {
    if (IndexReader.isLocked(directory)) {

> Exception during IndexWriter.close() prevents release of the write.lock
> -----------------------------------------------------------------------
>                 Key: LUCENE-748
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Bug
>    Affects Versions: 1.9
>         Environment: Lucene 1.4 through 2.1 HEAD (as of 2006-12-14)
>            Reporter: Jed Wesley-Smith
> After encountering a case of index corruption - see
- when the close() method encounters an exception in the flushRamSegments() method, the index
write.lock is not released (ie. it is not really closed).
> The writelock is only released when the IndexWriter is GC'd and finalize() is called.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message