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

Chris Nauroth commented on HDFS-5493:
-------------------------------------

Below is the offending code.  Thanks to [~avyakrita] for reporting the problem, 
and thanks to [~szetszwo] for finding the potential leak in the code.

There was some initial suspicion that this could be related to HDFS-3373, 
however the code is different on branch-1.  This is likely to be a different 
issue, though the symptoms are similar.

{code}
        } catch (IOException ex) {
          if (refetchToken > 0 && tokenRefetchNeeded(ex, targetAddr)) {
            refetchToken--;
            fetchBlockAt(target);
          } else {
            LOG.warn("Failed to connect to " + targetAddr
                + ", add to deadNodes and continue" + ex);
            if (LOG.isDebugEnabled()) {
              LOG.debug("Connection failure", ex);
            }
            // Put chosen node into dead list, continue
            addToDeadNodes(chosenNode);
          }
          if (s != null) {
            try {
              s.close();
            } catch (IOException iex) { }                        
          }
          s = null;
        }
{code}


> DFSClient#DFSInputStream#blockSeekTo may leak socket connection.
> ----------------------------------------------------------------
>
>                 Key: HDFS-5493
>                 URL: https://issues.apache.org/jira/browse/HDFS-5493
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: hdfs-client
>    Affects Versions: 1.2.1
>            Reporter: Chris Nauroth
>
> {{DFSClient#DFSInputStream#blockSeekTo}} may handle {{IOException}} by 
> refetching a new block access token and then reattempting {{fetchBlockAt}}.  
> However, {{fetchBlockAt}} may then throw its own {{IOException}}.  If this 
> happens, then the method skips calling {{Socket#close}}.  This is likely to 
> manifest as a leak of sockets left in CLOSE_WAIT status.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to