ConfX created YARN-11541:
----------------------------
Summary: AsyncDispatcher causes ArithmeticException due to
improper detailsInterval value checking
Key: YARN-11541
URL: https://issues.apache.org/jira/browse/YARN-11541
Project: Hadoop YARN
Issue Type: Bug
Reporter: ConfX
Attachments: reproduce.sh
h2. What happened
There is no value checking for parameter
{{{}yarn.dispatcher.print-events-info.threshold{}}}. This may cause improper
calculations and crashes the system like division by 0.
h2. Buggy code
In {{{}AsyncDispatcher.java{}}}, there is no value checking for
{{detailsInterval}} and this variable is directly used in the event handler.
When {{detailsInterval}} is mistakenly set to 0, the code would cause division
by 0 and throw ArithmeticException to crash the system.
```
public void handle(Event event) {
. . .
if (qSize != 0 && qSize % detailsInterval == 0 //
detailsInterval gets its value from the aforementioned config param
&& lastEventDetailsQueueSizeLogged != qSize) {
. . .
```
h2. How to reproduce
(1) set yarn.dispatcher.print-events-info.threshold=0
(2) run
org.apache.hadoop.yarn.event.TestAsyncDispatcher#testDispatcherMetricsHistogram
you should observe the following failure:
```
java.lang.ArithmeticException: / by zero
at
org.apache.hadoop.yarn.event.AsyncDispatcher$GenericEventHandler.handle(AsyncDispatcher.java:348)
at
org.apache.hadoop.yarn.event.TestAsyncDispatcher.testDispatcherMetricsHistogram(TestAsyncDispatcher.java:370)
...
```
For an easy reproduction, run the reproduce.sh in the attachment.
We are happy to provide a patch if this issue is confirmed.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]