[ 
https://issues.apache.org/jira/browse/HADOOP-12748?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sidharta Seethana updated HADOOP-12748:
---------------------------------------
    Description: 
When tasks running in a {{ThreadPoolExecutor}} throw an error/exception that is 
otherwise uncaught, it might not be propagated to the thread's uncaught 
exception handler because enclosing tasks (e.g {{FutureTask}}) might capture 
these exceptions (and do nothing). For more details, see : 
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.html#afterExecute-java.lang.Runnable-java.lang.Throwable-

To ensure such errors are logged, one mechanism would be to override 
{{ThreadPoolExecutor}} with an {{afterExecute}} method that would log these 
exceptions/errors. Logging these exceptions/errors would be useful in debugging 
issues that are otherwise difficult to trace (e.g YARN-4643) because there is 
nothing in the logs indicating an uncaught exception/error 

Some test code that demonstrates this issue is attached. 


  was:
{{ThreadPoolExecutor}} catches (otherwise uncaught) exceptions/errors thrown by 
the tasks running in the corresponding thread pool. These are passed to an 
{{afterExecute}} method which seems to do nothing by default unless overridden. 
 Even though we register {{UncaughtExceptionHandler}} s in various places (e.g 
{{YarnUncaughtExceptionHandler}}), these handlers are not invoked because the 
uncaught exceptions/errors are not propagated all the way  

To fix this, one mechanism would be to override {{ThreadPoolExecutor}} with an 
{{afterExecute}} method that would log these exceptions/errors. Logging these 
exceptions/errors would be useful in debugging issues that are otherwise 
difficult to trace (e.g YARN-4643) because there is nothing in the logs 
indicating an uncaught exception/error 

Edit: uploaded some test code that demonstrates this issue. 



> Uncaught exceptions are not caught/logged when ExecutorService is used
> ----------------------------------------------------------------------
>
>                 Key: HADOOP-12748
>                 URL: https://issues.apache.org/jira/browse/HADOOP-12748
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Sidharta Seethana
>            Assignee: Sidharta Seethana
>         Attachments: TestUncaughExceptionHandler.java
>
>
> When tasks running in a {{ThreadPoolExecutor}} throw an error/exception that 
> is otherwise uncaught, it might not be propagated to the thread's uncaught 
> exception handler because enclosing tasks (e.g {{FutureTask}}) might capture 
> these exceptions (and do nothing). For more details, see : 
> https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.html#afterExecute-java.lang.Runnable-java.lang.Throwable-
> To ensure such errors are logged, one mechanism would be to override 
> {{ThreadPoolExecutor}} with an {{afterExecute}} method that would log these 
> exceptions/errors. Logging these exceptions/errors would be useful in 
> debugging issues that are otherwise difficult to trace (e.g YARN-4643) 
> because there is nothing in the logs indicating an uncaught exception/error 
> Some test code that demonstrates this issue is attached. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to