Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-6455

Infinite loop in NetworkServerControlImpl.ensureDataInBuffer

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 10.10.1.1
    • Fix Version/s: 10.10.2.0, 10.11.1.1
    • Component/s: Network Server
    • Labels:
      None
    • Issue & fix info:
      High Value Fix, Known fix
    • Bug behavior facts:
      Performance, Seen in production

      Description

      NetworkServerControlImpl.ensureDataInBuffer missing check for return -1 (EOF) from 'clientIs.read'. When read returns -1 thread consumes 100% CPU. Method NetworkServerControlImpl.fillReplyBuffer correctly throw exception.

      Fix: add two lines:
      private void ensureDataInBuffer(int minimumBytesNeeded) throws Exception
      {
      // make sure the buffer is large enough
      while ((replyBufferCount - replyBufferPos) < minimumBytesNeeded)
      {
      try

      { int bytesRead = clientIs.read(replyBuffer, replyBufferCount, replyBuffer.length - replyBufferCount); + if (bytesRead == -1) + consolePropertyMessage("DRDA_InvalidReplyTooShort.S", true); replyBufferCount += bytesRead; }

      catch (IOException e)

      { clientSocketError(e); }

      }
      }

      StackTrace:
      java.lang.Thread.State: RUNNABLE
      at java.net.SocketInputStream.read(Unknown Source:-1)
      at org.apache.derby.impl.drda.NetworkServerControlImpl.ensureDataInBuffer(Unknown Source:-1)
      at org.apache.derby.impl.drda.NetworkServerControlImpl.readLDString(Unknown Source:-1)
      at org.apache.derby.impl.drda.NetworkServerControlImpl.readStringReply(Unknown Source:-1)
      at org.apache.derby.impl.drda.NetworkServerControlImpl.runtimeInfo(Unknown Source:-1)
      at org.apache.derby.drda.NetworkServerControl.getRuntimeInfo(Unknown Source:-1)
      at com.crcdata.dbadmin.server.DerbyEngine.getRuntimeInfo(DerbyEngine.java:134)
      at com.crcdata.dbadmin.server.DerbyEngine$DerbyServerMonitorTask.run(DerbyEngine.java:305)
      at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source:-1)
      at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source:-1)
      at java.util.concurrent.FutureTask.run(Unknown Source:-1)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source:-1)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source:-1)
      at java.lang.Thread.run(Unknown Source:-1)

        Attachments

        1. d6455-1a.diff
          5 kB
          Knut Anders Hatlen

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jandam@crcdata.cz Martin JANDA
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: