Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-4656

DN heartbeat loop can be briefly tight

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.0.4-alpha
    • None
    • datanode
    • None
    • Reviewed

    Description

      The DN hearbeat loop looks roughly like this:

      if (now - timeOfLastHeartbeat > configuredHeartbeatInterval) {
        // do heartbeat
      }
      timeToWait = configuredHeartbeatInterval - (now - timeOfLastHeartbeat)
      sleep(timeToWait)
      

      The trouble is that since we sleep for exactly the heartbeat interval, and then check to see if we have waited more than that heartbeat interval, we will very often have waited exactly the heartbeat interval (in millis), and not more than it. In this case we will skip actually performing the heartbeat and will calculcate timeToWait as being 0ms. The DN heartbeat loop will then loop tightly for 1ms. The solution is just to change the ">" in the code above to ">=".

      Attachments

        1. HDFS-4656.patch
          0.8 kB
          Aaron Myers

        Activity

          People

            atm Aaron Myers
            atm Aaron Myers
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: