cxzl25 opened a new pull request, #8998:
URL: https://github.com/apache/hadoop/pull/8998

   ### Description of PR
   
   `TestFairSchedulerPlanFollower` intermittently hangs in GitHub Actions until 
the job hits the 6h limit, for example:
   
   - https://github.com/cxzl25/hadoop/actions/runs/43359069221
   - https://github.com/cxzl25/hadoop/actions/runs/43401202274
   
   Looping the test in the CI image reproduced the hang in 5 of 558 runs. The 
thread dumps are identical. The update thread spins in `ComputeFairShares` 
while holding the read lock of the plan queue, and the test thread waits for 
the write lock of the same queue:
   
   ```
   "SchedulerUpdateThread" RUNNABLE (cpu=342s, elapsed=344s)
     at 
...fair.policies.ComputeFairShares.computeSharesInternal(ComputeFairShares.java:144)
     at ...fair.FSParentQueue.updateInternal(FSParentQueue.java:98)
     at ...fair.FairScheduler.update(FairScheduler.java:368)
   
   "main" WAITING
     at ...fair.FSParentQueue.addChildQueue(FSParentQueue.java:77)
     at 
...reservation.FairSchedulerPlanFollower.addReservationQueue(FairSchedulerPlanFollower.java:73)
     at 
...reservation.AbstractSchedulerPlanFollower.synchronizePlan(AbstractSchedulerPlanFollower.java:157)
   ```
   
   `FairScheduler#setEntitlement` changes the weight of a reservation queue 
without holding the scheduler lock, while `FairScheduler#update` computes fair 
shares under the write lock. `ComputeFairShares#computeSharesInternal` first 
sets aside the schedulables whose weight is 0, then doubles the 
weight-to-resource ratio until the resources used reach the total. If the plan 
follower sets the weight of the default reservation queue to 0 between those 
two steps, every share stays 0 and the loop never ends.
   
   This is not limited to the test. The plan follower and the update thread 
also run concurrently in a ResourceManager that uses FairScheduler with the 
reservation system enabled.
   
   This PR:
   
   - takes the scheduler write lock in `FairScheduler#setEntitlement`, so a 
weight can no longer change in the middle of a fair share computation;
   - bounds the doubling loop in `ComputeFairShares`, so the computation 
terminates even if a weight or a share is lowered while it runs.
   
   ### How was this patch tested?
   - Added `TestComputeFairShares#testWeightChangedToZeroDuringComputation`. It 
times out without the change to `ComputeFairShares` and passes with it.
   - Ran the tests under `resourcemanager/reservation` and 
`resourcemanager/scheduler/fair` locally with JDK 17: 813 tests, no failures.
   
   ### For code changes:
   
   - [ ] Does the title of this PR start with the corresponding JIRA issue id 
(e.g. 'HADOOP-17799. Your PR title ...')?
   - [ ] Object storage: Have the integration tests been executed and the 
endpoint
         declared according to the connector-specific documentation? *Note: 
Automated CI
         testing doesn't cover all cases so manual testing with cloud storage 
is still
         required.*
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, 
`NOTICE-binary` files?
   
   ### AI Tooling
   
   If an AI tool was used:
   
   - [ ] The PR includes the phrase "Contains content generated by <tool>"
         where <tool> is the name of the AI tool used.
   - [ ] My use of AI contributions follows the ASF legal policy
         https://www.apache.org/legal/generative-tooling.html
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to