You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Michael McCandless (JIRA)" <ji...@apache.org> on 2006/12/18 18:54:22 UTC

[jira] Commented: (LUCENE-748) Exception during IndexWriter.close() prevents release of the write.lock

    [ http://issues.apache.org/jira/browse/LUCENE-748?page=comments#action_12459419 ] 
            
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 {
    writer.close();
  } finally {
    if (IndexReader.isLocked(directory)) {
      IndexReader.unlock(directory);
    }
  }



> Exception during IndexWriter.close() prevents release of the write.lock
> -----------------------------------------------------------------------
>
>                 Key: LUCENE-748
>                 URL: http://issues.apache.org/jira/browse/LUCENE-748
>             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 http://issues.apache.org/jira/browse/LUCENE-140 - 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: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org