You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Jed Wesley-Smith (JIRA)" <ji...@apache.org> on 2006/12/15 06:13:22 UTC

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

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


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

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/LUCENE-748?page=comments#action_12459491 ] 
            
Michael McCandless commented on LUCENE-748:
-------------------------------------------

OK I will update the javadoc for IndexWriter.close to make this clear.  Thanks!

> 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


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

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/LUCENE-748?page=all ]

Michael McCandless reassigned LUCENE-748:
-----------------------------------------

    Assignee: Michael McCandless

> 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
>         Assigned To: Michael McCandless
>
> 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


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

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
    [ 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


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

Posted by "Hoss Man (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/LUCENE-748?page=comments#action_12459483 ] 
            
Hoss Man commented on LUCENE-748:
---------------------------------

given the changes made in LUCENE-702, i concur with your assesment Michael: keeping the lock open so that the caller can attempt to deal with the problem then retry makes sense.

even if we decided that the consistent state of the IndexWriter isn't an invarient that the user can rely on, asking users to forcably unlock in the event of an exception on close seems like a more reasonable expectation then to forcably unlock for them automatically.

> 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


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

Posted by "Jed Wesley-Smith (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/LUCENE-748?page=comments#action_12459489 ] 
            
Jed Wesley-Smith commented on LUCENE-748:
-----------------------------------------

I guess, particularly in light of LUCENE-702 that this behavior is OK - and the IndexReader.unlock(dir) is a good suggestion. My real problem was that the finalize() method does eventually remove the write lock. 

For me then the suggestion would be to document the exceptional behavior of the close() method (ie. it means that changes haven't been written and the write lock is still held) and link to the IndexReader.unlock(Directory) method.

> 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


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

Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/LUCENE-748?page=all ]

Michael McCandless resolved LUCENE-748.
---------------------------------------

    Fix Version/s: 2.1
       Resolution: Fixed

OK I just commited the fix to the javadoc.  Thanks Jed!

> 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
>         Assigned To: Michael McCandless
>             Fix For: 2.1
>
>
> 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


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

Posted by "Jed Wesley-Smith (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/LUCENE-748?page=comments#action_12459502 ] 
            
Jed Wesley-Smith commented on LUCENE-748:
-----------------------------------------

Awesome, thanks!

> 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
>         Assigned To: Michael McCandless
>
> 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