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

   Generated-by: Claude Code (Opus 5.5)
   
   JIRA: https://issues.apache.org/jira/browse/HDFS-18044
   
   ### Description of PR
   
   `TestBalancerRPCDelay` fails intermittently, and in recent trunk builds it 
hung the hadoop-hdfs unit tests until Jenkins killed the job (e.g. [PR-9015 
build 3](https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-9015/3/), 
[hadoop-qbt-trunk-java17 
#208](https://ci-hadoop.apache.org/job/hadoop-qbt-trunk-java17-linux-x86_64/208/)).
   
   `TestBalancer#spyFSNamesystem` installed the FSNamesystem spy into the 
running NameNode and only then stubbed it with 
`doAnswer(...).when(fsnSpy).getBlocks(...)`. Mockito attaches a pending 
`doAnswer` stub to the next call on the mock from any thread and skips that 
call's real method. So a NameNode thread's call could be swallowed:
   
   - a skipped `readUnlock()` or `writeUnlock()` leaks the namesystem lock, and 
`MiniDFSCluster#shutdown` then waits forever in 
`FSNamesystem#stopActiveServices` (the hang);
   - a skipped `writeLock()` makes the next `writeUnlock()` throw 
`IllegalMonitorStateException`;
   - a stub landing on a boolean method gives `ClassCastException ... Boolean 
cannot be cast to ... BlocksWithLocations` in the block report processor, and 
`UnfinishedStubbingException` in the test.
   
   This patch stubs the spy first and then installs it, through a new 
`NameNodeAdapterMockitoUtil#spyOnNamesystem(NameNode, FSNamesystem)` overload. 
The existing `spyOnNamesystem(NameNode)` delegates to it, so other callers are 
unchanged. Test code only.
   
   ### How was this patch tested?
   
   Local runs of `TestBalancerRPCDelay`, JDK 17, one JVM per run, 6 in 
parallel, with extra CPU load:
   
   | | trunk | with this patch |
   |---|---|---|
   | per method, 40 runs | 1 hang, 10 failed | 0 failed |
   | whole class, 15 runs | 4 failed | 0 failed |
   
   The hang reproduced locally with the same stack as described above (test 
thread blocked in `stopActiveServices` waiting for the write lock).
   
   ### For code changes:
   
   - [x] Does the title of this PR start with the corresponding JIRA issue id 
(e.g. 'HADOOP-17799. Your PR title ...')?
   
   ### AI Tooling
   
   - [x] The PR includes the phrase "Contains content generated by Claude Code".
   - [x] My use of AI contributions follows the ASF legal policy 
https://www.apache.org/legal/generative-tooling.html
   
   Contains content generated by Claude Code.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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

  • [PR] HDFS-18044. Stub the FSNa... smengcl (via GitHub) via common-issues

Reply via email to