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

Vinayakumar B commented on HDFS-7894:
-------------------------------------

Patch looks good.
Few nits:
below part also should be inside try block. otherwise lock will never be 
released.
{code}+    // check again after acquiring the read lock.
     RollingUpgradeInfo upgradeInfo = getRollingUpgradeInfo();
-    if (upgradeInfo != null) {
-      return new RollingUpgradeInfo.Bean(upgradeInfo);
+    if (upgradeInfo == null) {
+      return null;
     }{code}

2.
{code}+      boolean hasRollbackImage = this.getFSImage().hasRollbackFSImage();
+      upgradeInfo.setCreatedRollbackImages(hasRollbackImage);{code}
Here,  {{this.getFSImage().hasRollbackFSImage();}} will check for the image 
file presence on disk everytime query has passed. Actually this is required 
only if the flag is not set. Once its set, it will not be reset anyway until 
rollback/finalize.
It could be like 
{code}+      boolean hasRollbackImage = this.getFSImage().hasRollbackFSImage();
+      upgradeInfo.setCreatedRollbackImages(hasRollbackImage);{code}

IMO below changes would do needful.
{code}   @Override  // NameNodeMXBean
   public RollingUpgradeInfo.Bean getRollingUpgradeStatus() {
+    if (!isRollingUpgrade()) {
+      return null;
+    }
     RollingUpgradeInfo upgradeInfo = getRollingUpgradeInfo();
-    if (upgradeInfo != null) {
+    if (upgradeInfo.createdRollbackImages()) {
       return new RollingUpgradeInfo.Bean(upgradeInfo);
     }
-    return null;
+    readLock();
+    try {
+      // check again after acquiring the read lock.
+      upgradeInfo = getRollingUpgradeInfo();
+      if (upgradeInfo == null) {
+        return null;
+      }
+      if (!upgradeInfo.createdRollbackImages()) {
+        boolean hasRollbackImage = this.getFSImage().hasRollbackFSImage();
+        upgradeInfo.setCreatedRollbackImages(hasRollbackImage);
+      }
+    } catch (IOException ioe) {
+      LOG.warn("Encountered exception setting Rollback Image", ioe);
+    } finally {
+      readUnlock();
+    }
+    return new RollingUpgradeInfo.Bean(upgradeInfo);
   }{code}

Agree?

> Rolling upgrade readiness is not updated in jmx until query command is issued.
> ------------------------------------------------------------------------------
>
>                 Key: HDFS-7894
>                 URL: https://issues.apache.org/jira/browse/HDFS-7894
>             Project: Hadoop HDFS
>          Issue Type: Bug
>            Reporter: Kihwal Lee
>            Assignee: Brahma Reddy Battula
>            Priority: Critical
>         Attachments: HDFS-7894-002.patch, HDFS-7894.patch
>
>
> When a hdfs rolling upgrade is started and a rollback image is 
> created/uploaded, the active NN does not update its {{rollingUpgradeInfo}} 
> until it receives a query command via RPC. This results in inconsistent info 
> being showing up in the web UI and its jmx page.



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

Reply via email to