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

NPE in CapacityScheduler#tryCommit when handling allocate/reserve proposal whose allocatedOrReservedContainer is null

    XMLWordPrintableJSON

Details

    Description

      Recently we saw a NPE problem in CapacityScheduler#tryCommit when try to find the attemptId by calling c.getAllocatedOrReservedContainer().get... from an allocate/reserve proposal. But got null allocatedOrReservedContainer and thrown NPE.
      Reference code:

          // find the application to accept and apply the ResourceCommitRequest
          if (request.anythingAllocatedOrReserved()) {
            ContainerAllocationProposal<FiCaSchedulerApp, FiCaSchedulerNode> c =
                request.getFirstAllocatedOrReservedContainer();
            attemptId =
                c.getAllocatedOrReservedContainer().getSchedulerApplicationAttempt()
                    .getApplicationAttemptId();   //NPE happens here
          } else { ...
      

      The proposal was constructed in CapacityScheduler#createResourceCommitRequest and allocatedOrReservedContainer is possibly null in async-scheduling process when node was lost or application was finished (details in CapacityScheduler#getSchedulerContainer).
      Reference code:

            // Allocated something
            List<AssignmentInformation.AssignmentDetails> allocations =
                csAssignment.getAssignmentInformation().getAllocationDetails();
            if (!allocations.isEmpty()) {
              RMContainer rmContainer = allocations.get(0).rmContainer;
              allocated = new ContainerAllocationProposal<>(
                  getSchedulerContainer(rmContainer, true),   //possibly null
                  getSchedulerContainersToRelease(csAssignment),
                  getSchedulerContainer(csAssignment.getFulfilledReservedContainer(),
                      false), csAssignment.getType(),
                  csAssignment.getRequestLocalityType(),
                  csAssignment.getSchedulingMode() != null ?
                      csAssignment.getSchedulingMode() :
                      SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY,
                  csAssignment.getResource());
            }
      

      I think we should add null check for allocateOrReserveContainer before create allocate/reserve proposals. Besides the allocation process has increase unconfirmed resource of app when creating an allocate assignment, so if this check is null, we should decrease the unconfirmed resource of live app.

      Attachments

        1. YARN-8233.001.branch-2.patch
          13 kB
          Akira Ajisaka
        2. YARN-8233.001.branch-2.patch
          13 kB
          Tao Yang
        3. YARN-8233.001.branch-3.0.patch
          13 kB
          Akira Ajisaka
        4. YARN-8233.001.branch-3.0.patch
          13 kB
          Tao Yang
        5. YARN-8233.001.branch-3.1.patch
          12 kB
          Akira Ajisaka
        6. YARN-8233.001.branch-3.1.patch
          12 kB
          Tao Yang
        7. YARN-8233.001.patch
          5 kB
          Tao Yang
        8. YARN-8233.001-branch-3.1-test.patch
          13 kB
          Akira Ajisaka
        9. YARN-8233.001-test-branch-3.1.patch
          13 kB
          Akira Ajisaka
        10. YARN-8233.002.patch
          14 kB
          Tao Yang
        11. YARN-8233.003.patch
          12 kB
          Tao Yang

        Activity

          People

            Tao Yang Tao Yang
            Tao Yang Tao Yang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: