Support Questions

Find answers, ask questions, and share your expertise

Yarn RM crash by divided by zero error


We encounter a crash at Yarn ResourceManager several days ago:

2018-07-02 22:31:11,722 FATAL org.apache.hadoop.yarn.server.resourcemanager.ResourceManager: Error in handling event type NODE_UPDATE to the scheduler
java.lang.ArithmeticException: / by zero
        at org.apache.hadoop.yarn.util.resource.DominantResourceCalculator.computeAvailableContainers(
        at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue.assignContainer(
        at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue.assignOffSwitchContainers(
        at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue.assignContainersOnNode(
        at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue.assignContainers(
        at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ParentQueue.assignContainersToChildQueues(
        at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ParentQueue.assignContainers(
        at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ParentQueue.assignContainersToChildQueues(
        at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.ParentQueue.assignContainers(
        at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler.allocateContainersToNode(
        at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler.handle(
        at org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler.handle(
        at org.apache.hadoop.yarn.server.resourcemanager.ResourceManager$SchedulerEventDispatcher$
2018-07-02 22:31:11,722 INFO org.apache.hadoop.yarn.server.resourcemanager.ResourceManager: Exiting, bbye..


Looking into the codes (we're using cdh5.7.3), it looks like someone is requiring a resource with 0 vcores or memory:

113  @Override
114  public int computeAvailableContainers(Resource available, Resource required) {
115    return Math.min(
116        available.getMemory() / required.getMemory(), 
117        available.getVirtualCores() / required.getVirtualCores());
118  }

However, when searching in the Apache JIRA, only one ticket was found:

There's a patch attached in it after the ticket was closed and no more replies besides the patch's author's comment. Does the patch really fix the problem?

This crash happens only one time since we upgrade to cdh5.7.3 (~2 years ago). If this patch doesn't work, it'll also appear like it fixes the problem.


The patch adds a guard in AbstractYarnScheduler#getMaximumResourceCapability. However, the codes in this function were refactored after Yarn-2.9.0 by this commit (YARN-4719):

This refactoring is also applied to the later version of CDH, e.g. in cdh5.15 I can see the new codes.


I believe the bug was fixed in the community since there are no later discussions about it, neither fixed by the refactoring commit above or other commits later. Does anyone know more about this?


However, we can't upgrade our Yarn version in the near future. We still need a patch for the cdh5.7.3 version. Any advice for the patch?


Hopes someone in the Yarn community can help us. Thanks!


Super Collaborator

Hi stigahuang,


Cloudera has deprecated the capacity scheduler in CDH 5.8 as per the documentations: deprecated items.

We recommend that you move to the FairScheduler which we fully test and support. The difference between the upstream CS and what is in CDH is big and it is really difficult to say if a specific change would fix your issue or if a combination of changes would be needed.