Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-5553

IndexReader#ReaderClosedListener is not always called on IndexReader#close()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 4.7, 6.0
    • Fix Version/s: 4.7.1, 4.8, 6.0
    • Component/s: core/index
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      Today IndexReader#ReaderClosedListener might not be called if the last IndexReader#decRef() call runs into an exception on IndexReader#doClose(). Today we just reset the refCount and never go and call the listeners. There seem to be a bunch of problems here along the same lines but IMO if we close a reader it should close all resources no matter what exception it runs into. What this should do is call the close listeners in a finally block and then rethrow the exception. The real problem here for apps relying on the listener to release resources is that you might leak memory or file handles or whatnot which I think is a bug how we handle closing the IR. As a side-note I think we should never reset the reference here to be honest.

      Along the same lines I think we need to fix the loop in IndexReader#notifyReaderClosedListeners() to make sure we call all of them in the case any of them throws an exception. It also seems that SegmentCoreReaders#decRef() has a similar problem where for instance a fieldsReader can throw an exception on close and we never call the core listeners.

      IMO we need to fix this for 4.7.1

        Attachments

        1. LUCENE-5553.patch
          11 kB
          Simon Willnauer
        2. LUCENE-5553.patch
          12 kB
          Simon Willnauer
        3. LUCENE-5553.patch
          13 kB
          Simon Willnauer

          Activity

            People

            • Assignee:
              simonw Simon Willnauer
              Reporter:
              simonw Simon Willnauer
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: