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

xuzq commented on HDFS-15115:
-----------------------------

Thanks [~wzx513] for the report, I met this bug too.

I set the log level of BlockPlacementPolicyDefault from INFO to DEBUG by 
LogLevel to confirm somethings when the nameNode is running,  but the nameNode 
crashed by NPE in *builder.append()*. 

Checked the code and found, the *builder* may be not inited because the LOG 
level is INFO, but it be used after I set the LOG level to DEBUG by LogLevel.
{code:java}
StringBuilder builder = null;
if (LOG.isDebugEnabled()) {
  // it not be inited, because the LOG is not debugEnable.
  builder = debugLoggingBuilder.get();
  builder.setLength(0);
  builder.append("[");
}

if (LOG.isDebugEnabled()) {
  // it will be used, because i set the LOG level from INFO to DEBUG by 
LogLevel.
  builder.append("\nNode ").append(NodeBase.getPath(chosenNode))
      .append(" [");
}
{code}
 

 

[~belugabehr] do you have time to review this patch? I found you are more 
familiar with this logic, thanks.

 

> Namenode crash caused by NPE in BlockPlacementPolicyDefault when dynamically 
> change logger to debug
> ---------------------------------------------------------------------------------------------------
>
>                 Key: HDFS-15115
>                 URL: https://issues.apache.org/jira/browse/HDFS-15115
>             Project: Hadoop HDFS
>          Issue Type: Bug
>            Reporter: wangzhixiang
>            Priority: Major
>         Attachments: HDFS-15115.001.patch
>
>
> To get debug info, we dynamically change the logger of 
> BlockPlacementPolicyDefault to debug when namenode is running. However, the 
> Namenode crashs. From the log, we find some NPE in 
> BlockPlacementPolicyDefault.chooseRandom. Because *StringBuilder builder* 
> will be used 4 times in BlockPlacementPolicyDefault.chooseRandom method. 
> While the *builder* only initializes in the first time of this method. If we 
> change the logger of BlockPlacementPolicyDefault to debug after the part, the 
> *builder* in remaining part is *NULL* and cause *NPE*



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to