HerCath opened a new pull request, #4255:
URL: https://github.com/apache/hadoop/pull/4255
…king halt + enlarged catches (robustness) to all Throwables (not just
Exceptions)
<!--
Thanks for sending a pull request!
1. If this is your first time, please read our contributor guidelines:
https://cwiki.apache.org/confluence/display/HADOOP/How+To+Contribute
2. Make sure your PR title starts with JIRA issue id, e.g.,
'HADOOP-17799. Your PR title ...'.
-->
### Description of PR
I've reduced the synchronized blocks scope so System.exit and Runtime.halt
calls aren't within their boundaries, so ExitUtil wrappers do not block each
others (System.exit never returns if called and no SecurityException is raised,
so ExitUtil.terminate was never releasing the acquired lock, thus forbidding
ExitUtil.halt to be able to halt the JVM even when in the middle of a graceful
shutdown, thus it was not behaving like the 2 wrapped java's methods
System.exit/Runtime.halt which do not block each other)
I've altered throwable handling:
- what is catched: was nothing or only Exception, now all Throwables are
catched (even ThreadDeath)
- what is rethrown: when exit/halt has been disabled, if what was catched
is an Error it will be rethrown rather than the initial
ExitException/HaltException. Other Throwables will be added as suppressed to
the Exit/HaltException
- what wasn't catched: if not disabled, even is something was raised that
wasn't catched before, it is now catched and System.exit/Runtime.halt is always
called
- what is suppressed: if the what needs to be rethrown is changed on the
way, the newly to-be-thrown will have the old one as a suppressed Throwable.
I've also done this for the Exit/Halt Exception that can supress Throwables
that are not Error (might not be a so good idea)
### How was this patch tested?
No more tests than the existing ones (if any). This case is not really hard
to reproduce but the test would need to exit a JVM. I've not added such tests
because if unit does not fork, it would kills the test suite (thus impacting
all tests). I think developing a robust test for this specific case is way more
hard and dangerous to offset the cost of a review, the risk of what could be
missed by this review.
Easiest way can be reproduced the initial bug: having a shutdown hook call
ExitUtil.terminate, have another thread that will call ExitUtil.halt after (use
pauses to ensure it calls it after the hook), witness the JVM not stopping and
needing either an external kill or a internal Runtime.halt call, maybe check
the JVM threads' stacks too to view the ExitUtil.terminate call stuck on
System.exit, and ExitUtil.halt call stuck on ExitUtil.terminate.
### For code changes:
- [x] Does the title or this PR starts 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?
--
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]