Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.8.1, 4.9, 6.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      I'm working on a test case, and it hit OOME while writing the compound
      file; the test itself is separately buggy, but what was confounding
      was that CompoundFileWriter continued trying to write to the
      RAMOutputStream even after it had already hit OOME.

      RAMOutputStream could be better here (e.g. only increment
      currentBufferIndex if switchCurrentBuffer succeeds), but also I think
      we should fix CompoundFileWriter.close to .closeWhileHandlingExc even
      on non-IOExc.

      It results in scary looking excs like this:

      java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 2428, Size: 2427
      	at __randomizedtesting.SeedInfo.seed([4E313C43B4C1223B]:0)
      	at org.apache.lucene.index.TestIndexWriterThreadsToSegments$2.run(TestIndexWriterThreadsToSegments.java:222)
      Caused by: java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 2428, Size: 2427
      	at org.apache.lucene.index.TestIndexWriterThreadsToSegments$CheckSegmentCount.run(TestIndexWriterThreadsToSegments.java:137)
      	at java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:213)
      	at java.util.concurrent.CyclicBarrier.await(CyclicBarrier.java:355)
      	at org.apache.lucene.index.TestIndexWriterThreadsToSegments$2.run(TestIndexWriterThreadsToSegments.java:219)
      Caused by: java.lang.IndexOutOfBoundsException: Index: 2428, Size: 2427
      	at java.util.ArrayList.rangeCheck(ArrayList.java:604)
      	at java.util.ArrayList.get(ArrayList.java:382)
      	at org.apache.lucene.store.RAMFile.getBuffer(RAMFile.java:68)
      	at org.apache.lucene.store.RAMOutputStream.switchCurrentBuffer(RAMOutputStream.java:154)
      	at org.apache.lucene.store.RAMOutputStream.writeBytes(RAMOutputStream.java:138)
      	at org.apache.lucene.store.MockIndexOutputWrapper.writeBytes(MockIndexOutputWrapper.java:125)
      	at org.apache.lucene.store.MockIndexOutputWrapper.writeByte(MockIndexOutputWrapper.java:111)
      	at org.apache.lucene.store.DataOutput.writeInt(DataOutput.java:70)
      	at org.apache.lucene.codecs.CodecUtil.writeFooter(CodecUtil.java:184)
      	at org.apache.lucene.store.CompoundFileWriter.close(CompoundFileWriter.java:144)
      	at org.apache.lucene.store.CompoundFileDirectory.close(CompoundFileDirectory.java:178)
      	at org.apache.lucene.util.IOUtils.closeWhileHandlingException(IOUtils.java:88)
      	at org.apache.lucene.index.IndexWriter.createCompoundFile(IndexWriter.java:4512)
      	at org.apache.lucene.index.DocumentsWriterPerThread.sealFlushedSegment(DocumentsWriterPerThread.java:485)
      	at org.apache.lucene.index.DocumentsWriterPerThread.flush(DocumentsWriterPerThread.java:452)
      	at org.apache.lucene.index.DocumentsWriter.doFlush(DocumentsWriter.java:518)
      	at org.apache.lucene.index.DocumentsWriter.flushAllThreads(DocumentsWriter.java:629)
      	at org.apache.lucene.index.IndexWriter.getReader(IndexWriter.java:376)
      	at org.apache.lucene.index.StandardDirectoryReader.doOpenFromWriter(StandardDirectoryReader.java:285)
      	at org.apache.lucene.index.StandardDirectoryReader.doOpenIfChanged(StandardDirectoryReader.java:260)
      	at org.apache.lucene.index.StandardDirectoryReader.doOpenIfChanged(StandardDirectoryReader.java:250)
      	at org.apache.lucene.index.DirectoryReader.openIfChanged(DirectoryReader.java:124)
      	at org.apache.lucene.index.TestIndexWriterThreadsToSegments$CheckSegmentCount.run(TestIndexWriterThreadsToSegments.java:124)
      

        Activity

        Hide
        Robert Muir added a comment -

        I'll take it. This can cause OOM to "look like" index corruption. It needs to be fixed.

        Show
        Robert Muir added a comment - I'll take it. This can cause OOM to "look like" index corruption. It needs to be fixed.
        Hide
        Robert Muir added a comment -

        Here is a patch. The problem was IOUtils.closeWhileHandlingException(IOException, Closeable...)

        everywhere this was used, if some other throwable (e.g. OOME, some Error, etc) would strike, then you'd call close with a null IOException, and then throw the wrong exception.

        I removed this method.

        Show
        Robert Muir added a comment - Here is a patch. The problem was IOUtils.closeWhileHandlingException(IOException, Closeable...) everywhere this was used, if some other throwable (e.g. OOME, some Error, etc) would strike, then you'd call close with a null IOException, and then throw the wrong exception. I removed this method.
        Hide
        Michael McCandless added a comment -

        +1, looks great, thanks Rob!

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

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

        LUCENE-5654: Fix close methods that would suppress OOME or similar

        Show
        ASF subversion and git services added a comment - Commit 1593152 from Robert Muir in branch 'dev/trunk' [ https://svn.apache.org/r1593152 ] LUCENE-5654 : Fix close methods that would suppress OOME or similar
        Hide
        ASF subversion and git services added a comment -

        Commit 1593156 from Robert Muir in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1593156 ]

        LUCENE-5654: Fix close methods that would suppress OOME or similar

        Show
        ASF subversion and git services added a comment - Commit 1593156 from Robert Muir in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1593156 ] LUCENE-5654 : Fix close methods that would suppress OOME or similar
        Hide
        ASF subversion and git services added a comment -

        Commit 1593158 from Robert Muir in branch 'dev/branches/lucene_solr_4_8'
        [ https://svn.apache.org/r1593158 ]

        LUCENE-5654: Fix close methods that would suppress OOME or similar

        Show
        ASF subversion and git services added a comment - Commit 1593158 from Robert Muir in branch 'dev/branches/lucene_solr_4_8' [ https://svn.apache.org/r1593158 ] LUCENE-5654 : Fix close methods that would suppress OOME or similar
        Hide
        ASF subversion and git services added a comment -

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

        LUCENE-5654: add test for bugs related to OOM-handling

        Show
        ASF subversion and git services added a comment - Commit 1593171 from Robert Muir in branch 'dev/trunk' [ https://svn.apache.org/r1593171 ] LUCENE-5654 : add test for bugs related to OOM-handling
        Hide
        ASF subversion and git services added a comment -

        Commit 1593172 from Robert Muir in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1593172 ]

        LUCENE-5654: add test for bugs related to OOM-handling

        Show
        ASF subversion and git services added a comment - Commit 1593172 from Robert Muir in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1593172 ] LUCENE-5654 : add test for bugs related to OOM-handling
        Hide
        ASF subversion and git services added a comment -

        Commit 1593173 from Robert Muir in branch 'dev/branches/lucene_solr_4_8'
        [ https://svn.apache.org/r1593173 ]

        LUCENE-5654: add test for bugs related to OOM-handling

        Show
        ASF subversion and git services added a comment - Commit 1593173 from Robert Muir in branch 'dev/branches/lucene_solr_4_8' [ https://svn.apache.org/r1593173 ] LUCENE-5654 : add test for bugs related to OOM-handling
        Hide
        ASF subversion and git services added a comment -

        Commit 1593243 from Robert Muir in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1593243 ]

        LUCENE-5654: suppress 3.x codec

        Show
        ASF subversion and git services added a comment - Commit 1593243 from Robert Muir in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1593243 ] LUCENE-5654 : suppress 3.x codec
        Hide
        ASF subversion and git services added a comment -

        Commit 1593244 from Robert Muir in branch 'dev/branches/lucene_solr_4_8'
        [ https://svn.apache.org/r1593244 ]

        LUCENE-5654: suppress 3.x codec

        Show
        ASF subversion and git services added a comment - Commit 1593244 from Robert Muir in branch 'dev/branches/lucene_solr_4_8' [ https://svn.apache.org/r1593244 ] LUCENE-5654 : suppress 3.x codec

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development