Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-6416

Potential divide by zero issue in InputGateMetrics#refreshAndGetAvg()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.3.0, 1.4.0
    • Fix Version/s: 1.3.0, 1.4.0
    • Component/s: Metrics, Network
    • Labels:
      None

      Description

          int count = 0;
      
          for (InputChannel channel : inputGate.getInputChannels().values()) {
            if (channel instanceof RemoteInputChannel) {
              RemoteInputChannel rc = (RemoteInputChannel) channel;
      
              int size = rc.unsynchronizedGetNumberOfQueuedBuffers();
              total += size;
              ++count;
            }
          }
      
          return total / (float) count;
      

      If count is zero at the end of the loop, the division would produce exception.

        Issue Links

          Activity

          Hide
          greghogan Greg Hogan added a comment -

          Wouldn't this produce NaN?

          Show
          greghogan Greg Hogan added a comment - Wouldn't this produce NaN ?
          Hide
          yuzhihong@gmail.com Ted Yu added a comment - - edited

          I would think 0 is reasonable return value when both total and count are zero .

          Show
          yuzhihong@gmail.com Ted Yu added a comment - - edited I would think 0 is reasonable return value when both total and count are zero .
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user zentol opened a pull request:

          https://github.com/apache/flink/pull/3906

          FLINK-6416 Fix divide-by-zero in InputGateMetrics

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/zentol/flink 6416_metrics_zero

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/flink/pull/3906.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #3906


          commit 3772253a59f79667082d8fe599d85ad3590d7907
          Author: zentol <chesnay@apache.org>
          Date: 2017-05-15T11:44:54Z

          FLINK-6416 Fix divide-by-zero in InputGateMetrics


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user zentol opened a pull request: https://github.com/apache/flink/pull/3906 FLINK-6416 Fix divide-by-zero in InputGateMetrics You can merge this pull request into a Git repository by running: $ git pull https://github.com/zentol/flink 6416_metrics_zero Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/3906.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #3906 commit 3772253a59f79667082d8fe599d85ad3590d7907 Author: zentol <chesnay@apache.org> Date: 2017-05-15T11:44:54Z FLINK-6416 Fix divide-by-zero in InputGateMetrics
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user greghogan commented on the issue:

          https://github.com/apache/flink/pull/3906

          +1

          Show
          githubbot ASF GitHub Bot added a comment - Github user greghogan commented on the issue: https://github.com/apache/flink/pull/3906 +1
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user rmetzger commented on the issue:

          https://github.com/apache/flink/pull/3906

          +1

          Show
          githubbot ASF GitHub Bot added a comment - Github user rmetzger commented on the issue: https://github.com/apache/flink/pull/3906 +1
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user zentol commented on the issue:

          https://github.com/apache/flink/pull/3906

          merging.

          Show
          githubbot ASF GitHub Bot added a comment - Github user zentol commented on the issue: https://github.com/apache/flink/pull/3906 merging.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user zentol closed the pull request at:

          https://github.com/apache/flink/pull/3906

          Show
          githubbot ASF GitHub Bot added a comment - Github user zentol closed the pull request at: https://github.com/apache/flink/pull/3906
          Hide
          Zentol Chesnay Schepler added a comment -

          1.3: 979228b3e2cac52c79c78855645a536d515befc9
          1.4: c995ebd290b04c6426deff5a515ab0d0f1246ac7

          Show
          Zentol Chesnay Schepler added a comment - 1.3: 979228b3e2cac52c79c78855645a536d515befc9 1.4: c995ebd290b04c6426deff5a515ab0d0f1246ac7

            People

            • Assignee:
              Zentol Chesnay Schepler
              Reporter:
              yuzhihong@gmail.com Ted Yu
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development