Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-7664

IndexOutOfBoundsException thrown during repair

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Normal
    • Resolution: Fixed
    • Fix Version/s: 2.0.10
    • Component/s: None
    • Labels:
      None
    • Environment:

      RHEL 6.1
      Casandra 1.2.3 - 1.2.18

    • Severity:
      Normal

      Description

      I was running repair command with moderate read and write load at the same time. And I found tens of IndexOutOfBoundsException in system log as follows:

      ERROR [Thread-6056] 2013-05-22 14:47:59,416 CassandraDaemon.java (line132) Exception in thread Thread[Thread-6056,5,main]
      java.lang.IndexOutOfBoundsException
      at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:75)
      at org.apache.cassandra.streaming.compress.CompressedInputStream$Reader.runMayThrow(CompressedInputStream.java:151)
      at org.apache.cassandra.utils.WrappedRunnable.run(WrappedRunnable.java:28)
      at java.lang.Thread.run(Thread.java:662)

      I read the source code of CompressedInputStream.java and found there surely will throw IndexOutOfBoundsException in the following situation:

      CompressedInputStream.java
      // Part of CompressedInputStream.java start from Line 139
              protected void runMayThrow() throws Exception
              {
                  byte[] compressedWithCRC;
                  while (chunks.hasNext())
                  {
                      CompressionMetadata.Chunk chunk = chunks.next();
      
                      int readLength = chunk.length + 4; // read with CRC
                      compressedWithCRC = new byte[readLength];
      
                      int bufferRead = 0;
                      while (bufferRead < readLength)
                          bufferRead += source.read(compressedWithCRC, bufferRead, readLength - bufferRead);
                      dataBuffer.put(compressedWithCRC);
                  }
              }
      

      If read function read nothing because the end of the stream has been reached, it will return -1, thus bufferRead can be negetive. In the next circle, read function will throw IndexOutOfBoundsException because bufferRead is negetive.

        Attachments

        1. 0001-throw-EOFException-if-we-run-out-of-chunks-in-compre.patch
          5 kB
          Marcus Eriksson
        2. other-errors.txt
          1 kB
          Rick Branson
        3. $O[TOX~GGUZRW~IHPYPEG{0.jpg
          173 kB
          xiangdong Huang

          Activity

            People

            • Assignee:
              marcuse Marcus Eriksson
              Reporter:
              zhongyu09 Yu Zhong
              Authors:
              Marcus Eriksson
              Reviewers:
              Yuki Morishita
            • Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: