Lucene - Core
  1. Lucene - Core
  2. LUCENE-6120

how should MockIndexOutputWrapper.close handle exceptions in delegate.close

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0, 6.0
    • Component/s: core/store
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      Chasing a tricking Elasticsearch test failure, it came down to the delegate.close throwing an exception (ClosedByInterruptException, disturbingly, in this case), causing MockIndexOutputWrapper.close to fail to remove that IO from MDW's map.

      The question is, what should we do here, when delegate.close throws an exception? Is the delegate in fact closed, even when it throws an exception?

      Java8's docs on java.io.Closeable say this:

      As noted in AutoCloseable.close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

      And our OutputStreamIndexOutput is careful about this (flushes, then closes in a try-with-resources).

      So, I think MDW should be fixed to mark the IO as closed even if delegate.close throws an exception...

        Activity

        Hide
        Robert Muir added a comment -

        this is a test bug, but there are more bugs here in addition to this one.

        if close() is called multiple times, then disk usage computation and internal ref counting (trace through removeIndexOutput()) is wrong. that violates Closeable.close()

        Show
        Robert Muir added a comment - this is a test bug, but there are more bugs here in addition to this one. if close() is called multiple times, then disk usage computation and internal ref counting (trace through removeIndexOutput()) is wrong. that violates Closeable.close()
        Hide
        Robert Muir added a comment -

        Here are some improvements for Index/OutputWrapper.

        Show
        Robert Muir added a comment - Here are some improvements for Index/OutputWrapper.
        Hide
        Michael McCandless added a comment -

        +1, thanks Rob!

        Show
        Michael McCandless added a comment - +1, thanks Rob!
        Hide
        ASF subversion and git services added a comment -

        Commit 1647599 from Robert Muir in branch 'dev/trunk'
        [ https://svn.apache.org/r1647599 ]

        LUCENE-6120: Fix MockDirectoryWrapper close() handling

        Show
        ASF subversion and git services added a comment - Commit 1647599 from Robert Muir in branch 'dev/trunk' [ https://svn.apache.org/r1647599 ] LUCENE-6120 : Fix MockDirectoryWrapper close() handling
        Hide
        ASF subversion and git services added a comment -

        Commit 1647600 from Robert Muir in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1647600 ]

        LUCENE-6120: Fix MockDirectoryWrapper close() handling

        Show
        ASF subversion and git services added a comment - Commit 1647600 from Robert Muir in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1647600 ] LUCENE-6120 : Fix MockDirectoryWrapper close() handling
        Hide
        Anshum Gupta added a comment -

        Bulk close after 5.0 release.

        Show
        Anshum Gupta added a comment - Bulk close after 5.0 release.

          People

          • Assignee:
            Unassigned
            Reporter:
            Michael McCandless
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development