[ 
https://issues.apache.org/jira/browse/HDFS-16704?focusedWorklogId=797095&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-797095
 ]

ASF GitHub Bot logged work on HDFS-16704:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 02/Aug/22 02:31
            Start Date: 02/Aug/22 02:31
    Worklog Time Spent: 10m 
      Work Description: ZanderXu commented on PR #4661:
URL: https://github.com/apache/hadoop/pull/4661#issuecomment-1201945547

   @ayushtkn Thank you very much for helping me review it.
   
   Yes, you are right, we should return an empty value for this case. How about 
change it same with `getDiskBalancerStatus`, such as:
   ```
   @Override // DataNodeMXBean
     public String getVolumeInfo() {
       if (data == null) {
         LOG.debug("Storage not yet initialized.");
         return ""; // it's different with JSON.toString(new HashMap<String, 
Object>())
       }
       return JSON.toString(data.getVolumeInfoMap());
     }
   ```
   
   Developers or SREs are very sensitive to NPE, so I feel we shouldn't out put 
it in this expected situation.
   
   > Extra Stuff: This log line just below is wrong, incorrect placeholder, can 
fix in a separate jira if interested. :-)
   Copy, sir. I will fix it in a separate Jira.




Issue Time Tracking
-------------------

    Worklog Id:     (was: 797095)
    Time Spent: 0.5h  (was: 20m)

> Datanode return empty response instead of NPE for GetVolumeInfo during 
> restarting
> ---------------------------------------------------------------------------------
>
>                 Key: HDFS-16704
>                 URL: https://issues.apache.org/jira/browse/HDFS-16704
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>            Reporter: ZanderXu
>            Assignee: ZanderXu
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> During datanode starting, I found some NPE in logs:
> {code:java}
> Caused by: java.lang.NullPointerException: Storage not yet initialized
>     at 
> org.apache.hadoop.thirdparty.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:899)
>     at 
> org.apache.hadoop.hdfs.server.datanode.DataNode.getVolumeInfo(DataNode.java:3533)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke(Method.java:498)
>     at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:72)
>     at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
>     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke(Method.java:498)
>     at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:276)
>     at 
> com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:193)
>     at 
> com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:175)
>  {code}
> Because the storage of datanode not yet initialized when we trying to get 
> metrics of datanode, and related code as below:
> {code:java}
> @Override // DataNodeMXBean
> public String getVolumeInfo() {
>   Preconditions.checkNotNull(data, "Storage not yet initialized");
>   return JSON.toString(data.getVolumeInfoMap());
> } {code}
> The logic is ok, but I feel that the more reasonable logic should be return 
> an empty response instead of NPE, because InfoServer will be started before 
> initBlockPool.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to