Uploaded image for project: 'Hadoop YARN'
  1. Hadoop YARN
  2. YARN-4089

Race condition when calling AbstractYarnScheduler.completedContainer.



    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.6.0, 2.7.0, 2.5.2, 2.7.1
    • Fix Version/s: None
    • Component/s: fairscheduler
    • Labels:
    • Flags:


      There is a race condition of calling AbstractYarnScheduler.completedContainer, which will cause the usedResource counter of application not accurate. At worst situation, the scheduler will not allocate any resource to any application in some queue( when the usedResource became negative) even there is indeed lots of free resource to be allocated.

      It also cause the Scheduler UI and metrics report negative resource usage value.In our cluster, it has the ability to run 13000+ container, but the WEB UI says that:

      • Containers Running: -26546
      • Memory Used: -82.38 TB
      • VCores Used: -26451

      This is how it happens in FairSchedular:

      completedContainer method will call application.containerCompleted, which will subtraction the resources used by this container from the usedResource counter of the application. So, if the completedContainer are called twice with the same container, the counter is subtracted too much values. So is the updateRootQueueMetrics call, so we can see negative allocatedMemory on rootQueue.

      The solution is to check whether the container being supplied is still live inside the completedContainer (as shown in the patch). There is some check before calling completedContainer, but that's not enough.

      For a more deeply discussion, the completedContainer may be called from two place:

      1. Trigered by RMContainerEventType.FINISHED event:

      // Process completed containers
          for (ContainerStatus completedContainer : completedContainers) {
            ContainerId containerId = completedContainer.getContainerId();
            LOG.debug("Container FINISHED: " + containerId);
                completedContainer, RMContainerEventType.FINISHED);

      2. Trigered by RMContainerEventType.RELEASED

                SchedulerUtils.RELEASED_CONTAINER), RMContainerEventType.RELEASED);

      RMContainerEventType.RELEASED is not triggered by MapReduce ApplicationMaster, so we won't see this problem on MR jobs. But TEZ will triggered it when it do not need this this container, while the NodeManger will also report a container complete message to RM ,which in turn trigger the RMContainerEventType.FINISHED event. If RMContainerEventType.FINISHED event comes to RM early than TEZ AM, the problem happens.

      This behavior can be more easily seen if the cluster had setup a TimelineServer for TEZ, which make it more likely TEZ AM will send RMContainerEventType.RELEASED event later than NM send RMContainerEventType.FINISHED.


        1. YARN-4089.001.patch
          1 kB
          Shiwei Guo

          Issue Links



              • Assignee:
                guoshiwei Shiwei Guo
              • Votes:
                0 Vote for this issue
                9 Start watching this issue


                • Created: