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

   ### Description of PR
   
   JIRA: https://issues.apache.org/jira/browse/HADOOP-20066
   
   For an unknown size, `AllocatorPerContext#getLocalPathForWrite` picks a 
directory at random, weighted by free space, and subtracts a directory's space 
from `totalAvailable` when `createPath()` fails for it. A directory with no 
usable space still counts toward `numDirs`, so after every directory with space 
has failed, `totalAvailable` is 0 while the loop still runs, and `(r.nextLong() 
>>> 1) % totalAvailable` throws `ArithmeticException: / by zero` instead of the 
`DiskErrorException` that lists the directories. One full disk plus a disk 
remounted read-only is enough, and since the context is only rebuilt when the 
configuration changes, every such allocation in that JVM fails the same way.
   
   This patch adds `totalAvailable > 0` to the loop condition, so the existing 
`DiskErrorException` is thrown. HADOOP-9079 proposed the same change in 2012, 
but it was not committed.
   
   ### How was this patch tested?
   
   Added `TestLocalDirAllocator#testGetLocalPathForWriteWhenAllDirsFailCreate` 
(parameterized like its neighbours): one buffer directory is removed and cannot 
be recreated, the other is made read-only, and `getLocalPathForWrite` must 
throw `DiskErrorException` naming both. Without the fix it throws 
`ArithmeticException`.
   
   ### For code changes:
   
   - [x] 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?
   - [ ] 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
   
   - [x] The PR includes the phrase "Contains content generated by Claude Opus".
   - [x] My use of AI contributions follows the ASF legal policy 
https://www.apache.org/legal/generative-tooling.html
   
   Contains content generated by Claude Opus.
   


-- 
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