Uploaded image for project: 'ORC'
  1. ORC
  2. ORC-381

OutStream.write hangs with misconfigured bufferSize

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.5.1
    • None
    • None
    • None

    Description

      When the bufferSize is configured to be 0 in the class initialization, the while loop in OutStream.write function hangs endlessly.
      This is because when the bufferSize is 0, current.remaining is 0, length will always > 0.
      Here is the code snippet.

         OutStream(String name, int bufferSize, CompressionCodec codec, OutputReceiver receiver) throws IOException {
          ...
          this.bufferSize = bufferSize; //bufferSize can be configured with 0
          ...
        }
      
          private void getNewInputBuffer() throws IOException {
            ...
            current = ByteBuffer.allocate(bufferSize);
            ...
        }
      
        public void write(byte[] bytes, int offset, int length) throws IOException {
          if (current == null) {
            getNewInputBuffer();
          }
          int remaining = Math.min(current.remaining(), length);
          current.put(bytes, offset, remaining);
          uncompressedBytes += remaining;
          length -= remaining;
          while (length != 0) {//length > 0
            spill();
            offset += remaining;
            remaining = Math.min(current.remaining(), length);//current.remaining() == 0
            current.put(bytes, offset, remaining);
            uncompressedBytes += remaining;
            length -= remaining;
          }
        }
      

      The similar case is HDFS-13513, HDFS-13514

      Attachments

        Activity

          People

            Unassigned Unassigned
            dustinday John Doe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: