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

Karthik Kambatla commented on MAPREDUCE-5723:
---------------------------------------------

I think the clean way, though slightly more involved, would be to have 
MRAppMaster implement serviceStop() and call LogManager.shutdown() there. 

While at it, I also think the {{MRAppMasterShutdownHook}} should only call 
appMaster.stop() and rest of the items should move to serviceStop().
{code}
    public void run() {
      LOG.info("MRAppMaster received a signal. Signaling RMCommunicator and "
        + "JobHistoryEventHandler.");

      // Notify the JHEH and RMCommunicator that a SIGTERM has been received so
      // that they don't take too long in shutting down
      if(appMaster.containerAllocator instanceof ContainerAllocatorRouter) {
        ((ContainerAllocatorRouter) appMaster.containerAllocator)
          .setSignalled(true);
      }
      appMaster.notifyIsLastAMRetry(appMaster.isLastAMRetry);
      appMaster.stop();
    }
{code}

Further, instead of calling System.exit(1), we should call 
ExitUtil.terminate(1, t):
{code}
    } catch (Throwable t) {
      LOG.fatal("Error starting MRAppMaster", t);
      System.exit(1);
{code}

> MR AM container log empty if exception occurs
> ---------------------------------------------
>
>                 Key: MAPREDUCE-5723
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-5723
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>          Components: applicationmaster
>    Affects Versions: 2.2.0
>            Reporter: Mohammad Kamrul Islam
>            Assignee: Mohammad Kamrul Islam
>             Fix For: trunk, 2.2.0
>
>         Attachments: MAPREDUCE-5723.1.patch, MAPREDUCE-5723.2.patch
>
>
> It occurs when the property "mapreduce.task.userlog.limit.kb" is set non-zero 
> in mapped-site.xml.
> AM container syslog remains empty if any exception occurs. 
> Bug details:
> In MRAppMaster.java, the following code snippets show the bug.
> } catch (Throwable t) {
>        LOG.fatal("Error starting MRAppMaster", t);
>       System.exit(1);
>     }finally {
>        LogManager.shutdown();
>      }
> In the catch block, we are exiting the JVM. So finally block (therefore 
> LogManager.shutdown()) is never executed.
> Possible fix: 
> Make sure LogManager.shutdown() is executed in all cases.
>  



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to