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

Jason Lowe commented on MAPREDUCE-6261:
---------------------------------------

The flush method can be invoked twice if we get an exception during flush/close 
of the map output collector due to the following code in MapTask (this is for 
new API but the same setup occurs for the old API as well):

{code}
    try {
[...]
      output.close(mapperContext);
      output = null;
    } finally {
      closeQuietly(input);
      closeQuietly(output, mapperContext);
    }
{code}

The close method invokes the flush method, and if we throw during the close we 
will try to close (and flush) again.  If we throw trying to close *after* the 
flush method has already set kvbuffer to null we will turn around and try to 
close and flush again due to the finally clause and encounter the NPE.

Here's a sample stacktrace.  Note that the exceptions are logged in the reverse 
order of when they occurred due to the finally clause:

{noformat}
2015-02-12 07:42:01,482 INFO [main] org.apache.hadoop.mapred.MapTask: Ignoring 
exception during close for 
org.apache.hadoop.mapred.MapTask$NewOutputCollector@1234
java.lang.NullPointerException
    at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.flush(MapTask.java:1447)
    at 
org.apache.hadoop.mapred.MapTask$NewOutputCollector.close(MapTask.java:700)
    at org.apache.hadoop.mapred.MapTask.closeQuietly(MapTask.java:1990)
    at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:774)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:415)
    at 
org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1637)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163)
2015-02-12 07:42:01,484 WARN [main] org.apache.hadoop.mapred.YarnChild: 
Exception running child :
org.apache.hadoop.util.DiskChecker$DiskErrorException: Could not find any valid 
local directory for output/attempt_1416815736267_5558092_m_000000_0/file.out
    at 
org.apache.hadoop.fs.LocalDirAllocator$AllocatorPerContext.getLocalPathForWrite(LocalDirAllocator.java:402)
    at 
org.apache.hadoop.fs.LocalDirAllocator.getLocalPathForWrite(LocalDirAllocator.java:150)
    at 
org.apache.hadoop.fs.LocalDirAllocator.getLocalPathForWrite(LocalDirAllocator.java:131)
    at 
org.apache.hadoop.mapred.YarnOutputFiles.getOutputFileForWrite(YarnOutputFiles.java:84)
    at 
org.apache.hadoop.mapred.MapTask$MapOutputBuffer.mergeParts(MapTask.java:1813)
    at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.flush(MapTask.java:1484)
    at 
org.apache.hadoop.mapred.MapTask$NewOutputCollector.close(MapTask.java:700)
    at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:770)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:340)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:168)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:415)
    at 
org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1637)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:163)
{noformat}

> NullPointerException if MapOutputBuffer.flush invoked twice
> -----------------------------------------------------------
>
>                 Key: MAPREDUCE-6261
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-6261
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>          Components: mrv2
>    Affects Versions: 2.5.0
>            Reporter: Jason Lowe
>
> MapOutputBuffer.flush will throw an NPE if it is invoked twice, since it 
> blindly assumes kvbuffer is not null yet sets kvbuffer to null towards the 
> end of the method.



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

Reply via email to