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

CFS leaks a file on exception opening it

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Cannot Reproduce
    • None
    • None
    • core/codecs
    • None
    • New

    Description

      If CFS hits an exception opening its file, it will leak the file handle. Found by Jenkins: https://jenkins.thetaphi.de/job/Lucene-Solr-7.x-Solaris/808/

       java.lang.RuntimeException: MockDirectoryWrapper: cannot close: there are still 7 open files: {_j.cfs=1, _h.cfs=1, _e.cfs=1, _g.cfs=1, _i.cfs=1, _k.cfs=1, _f.cfs=1}
      ...
      Caused by: java.lang.RuntimeException: unclosed IndexInput: _f.cfs
              at org.apache.lucene.store.MockDirectoryWrapper.addFileHandle(MockDirectoryWrapper.java:730)
              at org.apache.lucene.store.MockDirectoryWrapper.openInput(MockDirectoryWrapper.java:773)
              at org.apache.lucene.codecs.lucene50.Lucene50CompoundReader.<init>(Lucene50CompoundReader.java:78)
      

      Looks like it needs to move opening of handle into the try block (untested):

      diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50CompoundReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50CompoundReader.java
      index 7526c88c20..db54ecdee2 100644
      --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50CompoundReader.java
      +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene50/Lucene50CompoundReader.java
      @@ -75,8 +75,8 @@ final class Lucene50CompoundReader extends Directory {
           }
           expectedLength += CodecUtil.footerLength(); 
       
      -    handle = directory.openInput(dataFileName, context);
           try {
      +      handle = directory.openInput(dataFileName, context);
             CodecUtil.checkIndexHeader(handle, Lucene50CompoundFormat.DATA_CODEC, version, version, si.getId(), "");
             
             // NOTE: data file is too costly to verify checksum against all the bytes on open,
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            rcmuir Robert Muir
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: