You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ambari.apache.org by "Hadoop QA (JIRA)" <ji...@apache.org> on 2017/06/15 10:32:00 UTC

[jira] [Commented] (AMBARI-21248) Exception needs to be handled properly for mail alert

    [ https://issues.apache.org/jira/browse/AMBARI-21248?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16050297#comment-16050297 ] 

Hadoop QA commented on AMBARI-21248:
------------------------------------

{color:red}-1 overall{color}.  Here are the results of testing the latest attachment 
  http://issues.apache.org/jira/secure/attachment/12873092/AMBARI-21248.patch
  against trunk revision .

    {color:green}+1 @author{color}.  The patch does not contain any @author tags.

    {color:red}-1 tests included{color}.  The patch doesn't appear to include any new or modified tests.
                        Please justify why no new tests are needed for this patch.
                        Also please list what manual steps were performed to verify this patch.

    {color:green}+1 release audit{color}.  The applied patch does not increase the total number of release audit warnings.

    {color:green}+1 javac{color}.  The applied patch does not increase the total number of javac compiler warnings.

    {color:green}+1 core tests{color}.  The patch passed unit tests in ambari-server.

Console output: https://builds.apache.org/job/Ambari-trunk-test-patch/11652//console

This message is automatically generated.

> Exception needs to be handled properly for mail alert
> -----------------------------------------------------
>
>                 Key: AMBARI-21248
>                 URL: https://issues.apache.org/jira/browse/AMBARI-21248
>             Project: Ambari
>          Issue Type: Bug
>          Components: ambari-server
>    Affects Versions: 2.4.2
>            Reporter: Richard Zang
>            Assignee: Dmytro Sen
>            Priority: Critical
>             Fix For: 2.5.2
>
>         Attachments: AMBARI-21248.patch
>
>
> In org.apache.ambari.server.state.services.AlertNoticeDispatchService, we have below code snippet:
> {code}
> ... 
> protected void runOneIteration() throws Exception { 
> … 
> String targetType = target.getNotificationType(); 
> NotificationDispatcher dispatcher = m_dispatchFactory.getDispatcher(targetType); 
> … 
> if (dispatcher.isDigestSupported()) { 
> ...
> {code}
> If the database has a change to AlertTargetEntity's targetType column (unlikely but let's assume it happened), then dispatcher can be null and the subsequent if clause will throw an exception. In https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java, we see that the exception may happen silently since shutDown() and notifyFailed() does not log anything. 
> ... 
> {code}
> class Task implements Runnable {
>     @Override
>     public void run() {
>         lock.lock();
>         try {
>             if (runningTask.isCancelled()) { // task may have been cancelled while blocked on the lock. return; }
>                 AbstractScheduledService.this.runOneIteration();
>             } catch (Throwable t) {
>                 try {
>                     shutDown();
>                 } catch (Exception ignored) {
>                     logger.log(Level.WARNING, "Error while attempting to shut down the service after failure.", ignored);
>                 }
>                 notifyFailed(t);
>                 runningTask.cancel(false); // prevent future invocations. 
>             } finally {
>                 lock.unlock();
>             }
>         }
>     }
> }
> {code}
> So, runOneIteration will shutdown the scheduler if it hits an uncaught exception. We should wrap a try/catch.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)