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

IndexReader.open(String|File) may incorrectly throw AlreadyClosedException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1, 2.2, 2.3, 2.3.1, 2.3.2, 2.4
    • Fix Version/s: 2.4.1, 2.9
    • Component/s: core/index
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      Spinoff from here:

      http://www.nabble.com/Runtime-exception-when-creating-IndexSearcher-to20226279.html

      If you open an IndexSearcher/Reader, passing in String or File, then
      closeDirectory is set to true in the reader.

      If the index has a single segment, then SegmentReader.get is used to
      open the index. If an IOException is hit in there, the SegmentReader
      closes itself and then closes the directory since closeDirectory is
      true.

      The problem is, the retry logic in SegmentInfos (to look for another
      segments_N to try) kicks in and hits an AlreadyClosedException,
      masking the original root cause.

      Workaround is to separately get the Directory using
      FSDirectory.getDirectory, and then instantiate IndexSearcher/Reader
      from that.

      This manifests as masking the root cause of a corrupted single-segment
      index with a confusing AlreadyClosedException. You could also hit
      the false exception if the writer was in the process of committing
      (ie, a retry was really needed) or if there is some transient IO
      problem opening the index (eg too many open files).

      1. LUCENE-1430.patch
        4 kB
        Michael McCandless

        Activity

        Hide
        mikemccand Michael McCandless added a comment -

        Attached patch. I plan to commit in a day or so.

        Show
        mikemccand Michael McCandless added a comment - Attached patch. I plan to commit in a day or so.
        Hide
        mikemccand Michael McCandless added a comment -

        Committed revision 709456.

        Show
        mikemccand Michael McCandless added a comment - Committed revision 709456.
        Hide
        mikemccand Michael McCandless added a comment -

        Reopening for backport to 2.4.1.

        Show
        mikemccand Michael McCandless added a comment - Reopening for backport to 2.4.1.
        Hide
        mikemccand Michael McCandless added a comment -

        Committed revision 745794 on 2.4 branch.

        Show
        mikemccand Michael McCandless added a comment - Committed revision 745794 on 2.4 branch.

          People

          • Assignee:
            mikemccand Michael McCandless
            Reporter:
            mikemccand Michael McCandless
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development