You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Robert Muir (JIRA)" <ji...@apache.org> on 2018/09/09 15:46:00 UTC

[jira] [Created] (LUCENE-8494) CFS leaks a file on exception opening it

Robert Muir created LUCENE-8494:
-----------------------------------

             Summary: CFS leaks a file on exception opening it
                 Key: LUCENE-8494
                 URL: https://issues.apache.org/jira/browse/LUCENE-8494
             Project: Lucene - Core
          Issue Type: Bug
          Components: core/codecs
            Reporter: Robert Muir


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/

{noformat}
 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)
{noformat}

Looks like it needs to move opening of {{handle}} into the try block (untested):
{noformat}
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,
{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org