You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/10/06 17:26:55 UTC

[GitHub] [helix] zhangmeng916 opened a new pull request #1441: Catch exception in group commit

zhangmeng916 opened a new pull request #1441:
URL: https://github.com/apache/helix/pull/1441


   ### Issues
   
   - [X] My PR addresses the following Helix issues and references them in the PR description:
   
   Fixed #1440 
   
   ### Description
   
   - [X] Here are some details about my PR, including screenshots of any UI changes:
   
   In group commit commit function, the return value is true or false, denoting whether the group commit succeed or not. However, in the read data path, if there is an exception such as zkclient is closed, etc., an exception will still be thrown in group commit. This is inconsistent with group commit java doc, and also different from normal update zk operation, which catches all exception.
   This PR catches all exception in commit function.
   
   ### Tests
   
   - [ ] The following tests are written for this issue:
   
   (List the names of added unit/integration tests)
   
   - [ ] The following is the result of the "mvn test" command on the appropriate module:
   
   (Before CI test pass, please copy & paste the result of "mvn test")
   
   ### Documentation (Optional)
   
   - In case of new functionality, my PR adds documentation in the following wiki page:
   
   (Link the GitHub wiki you added)
   
   ### Commits
   
   - My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Code Quality
   
   - My diff has been formatted using helix-style.xml 
   (helix-style-intellij.xml if IntelliJ IDE is used)
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] zhangmeng916 commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
zhangmeng916 commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500492225



##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -112,6 +112,9 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
             merged = accessor.get(mergedKey, null, options);
           } catch (ZkNoNodeException e) {
             // OK.
+          } catch (Exception e) {

Review comment:
       Yep, I'll address them together with #1436 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500609429



##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -139,14 +142,22 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
           success = false;
           while (++retry <= MAX_RETRY && !success) {
             if (removeIfEmpty && merged.getMapFields().isEmpty()) {
-              success = accessor.remove(mergedKey, options);
+              try {
+                success = accessor.remove(mergedKey, options);
+              } catch (Exception e) {
+                success = false;

Review comment:
       The thing is that we did not log out the exception. At the time of investigation of production issue, you always want to know what is the exception thrown.
   
   Current code actually "eat" the exception from IO (zk access). This is normally not a good idea.
   
   how about something like this:
   
   ```
    try {
                   success = accessor.remove(mergedKey, options);
     } catch (Exception e) {
                   LOG.error (" failed to remove {} from zk, retry it", mergedkey, e);
                   return false;
     }
   
    LOG.info( "removed {}", mergedkey);
   ```
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500597689



##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -139,14 +142,22 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
           success = false;
           while (++retry <= MAX_RETRY && !success) {
             if (removeIfEmpty && merged.getMapFields().isEmpty()) {
-              success = accessor.remove(mergedKey, options);
+              try {
+                success = accessor.remove(mergedKey, options);
+              } catch (Exception e) {
+                success = false;
+              }
               if (!success) {
                 LOG.error("Fails to remove " + mergedKey + " from ZK, retry it!");
               } else {
                 LOG.info("Removed " + mergedKey);
               }
             } else {
-              success = accessor.set(mergedKey, merged, options);
+              try {
+                success = accessor.set(mergedKey, merged, options);
+              } catch (Exception e) {
+                success = false;

Review comment:
       log exception here. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] zhangmeng916 commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
zhangmeng916 commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500605834



##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -139,14 +142,22 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
           success = false;
           while (++retry <= MAX_RETRY && !success) {
             if (removeIfEmpty && merged.getMapFields().isEmpty()) {
-              success = accessor.remove(mergedKey, options);
+              try {
+                success = accessor.remove(mergedKey, options);
+              } catch (Exception e) {
+                success = false;

Review comment:
       if you look at the next line. It's already logged there. 

##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -139,14 +142,22 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
           success = false;
           while (++retry <= MAX_RETRY && !success) {
             if (removeIfEmpty && merged.getMapFields().isEmpty()) {
-              success = accessor.remove(mergedKey, options);
+              try {
+                success = accessor.remove(mergedKey, options);
+              } catch (Exception e) {
+                success = false;
+              }
               if (!success) {
                 LOG.error("Fails to remove " + mergedKey + " from ZK, retry it!");
               } else {
                 LOG.info("Removed " + mergedKey);
               }
             } else {
-              success = accessor.set(mergedKey, merged, options);
+              try {
+                success = accessor.set(mergedKey, merged, options);
+              } catch (Exception e) {
+                success = false;

Review comment:
       It's logged next line.

##########
File path: helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
##########
@@ -1315,8 +1315,11 @@ public void addTypeToCustomizedStateConfig(String clusterName, String type) {
     ZKHelixDataAccessor accessor =
         new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
     PropertyKey.Builder keyBuilder = accessor.keyBuilder();
-    accessor.updateProperty(keyBuilder.customizedStateConfig(),
-        customizedStateConfigFromBuilder);
+    if(!accessor.updateProperty(keyBuilder.customizedStateConfig(),

Review comment:
       The reason we need this PR is that we need to make sure updateProperty with group commit or non group commit have the same behavior. Currently non group commit update return error code, while group commit throws exception. This should not impact any callbackhandler existing logic.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500609429



##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -139,14 +142,22 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
           success = false;
           while (++retry <= MAX_RETRY && !success) {
             if (removeIfEmpty && merged.getMapFields().isEmpty()) {
-              success = accessor.remove(mergedKey, options);
+              try {
+                success = accessor.remove(mergedKey, options);
+              } catch (Exception e) {
+                success = false;

Review comment:
       The thing is that we did not log out the exception. At the time of investigation of production issue, you always want to know what is the exception thrown.
   
   Current code actually "eat" the exception from IO (zk access). This is normally not a good idea.
   
   how about something like this?
   
   ```
    try {
                   success = accessor.remove(mergedKey, options);
     } catch (Exception e) {
                   LOG.error (" failed to remove {} from zk, retry it", mergedkey, e);
                   return false;
     }
   
    LOG.info( "removed {}", mergedkey);
   ```
   
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500479923



##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -112,6 +112,9 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
             merged = accessor.get(mergedKey, null, options);

Review comment:
       I suggest covering all the accessor related calls inside the commit(). There should be 3 as I remember.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] zhangmeng916 commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
zhangmeng916 commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500531715



##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -112,6 +112,9 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
             merged = accessor.get(mergedKey, null, options);
           } catch (ZkNoNodeException e) {
             // OK.
+          } catch (Exception e) {

Review comment:
       This change only impacts group commit. As shown in the following, only current state and customized state use group commit. 
   case CURRENTSTATES:
   case CUSTOMIZEDSTATES:
           success = _groupCommit.commit(_baseDataAccessor, options, path, value.getRecord(), true);
   
   However, as you mentioned, for normal update, there're cases that don't really check response. I'll take a look to see whether they're reasonable. 
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] lei-xia commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
lei-xia commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500485957



##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -112,6 +112,9 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
             merged = accessor.get(mergedKey, null, options);
           } catch (ZkNoNodeException e) {
             // OK.
+          } catch (Exception e) {

Review comment:
       There are a few places that call DataAccessor.updateProperty but did not check the return results, we may want to double check whether it is appropriate (i.e, adding check there if it cares writing failure).
   
   one example is:  HelixAdmin->addTypeToCustomizedStateConfig()




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang merged pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
jiajunwang merged pull request #1441:
URL: https://github.com/apache/helix/pull/1441


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] zhangmeng916 commented on pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
zhangmeng916 commented on pull request #1441:
URL: https://github.com/apache/helix/pull/1441#issuecomment-704544728


   This PR is ready to merge. Approved by @jiajunwang 
   Final commit message:
   Catch exception in group commit.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] lei-xia commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
lei-xia commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500486098



##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -112,6 +112,9 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
             merged = accessor.get(mergedKey, null, options);

Review comment:
       What do you mean?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500598458



##########
File path: helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
##########
@@ -1315,8 +1315,11 @@ public void addTypeToCustomizedStateConfig(String clusterName, String type) {
     ZKHelixDataAccessor accessor =
         new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
     PropertyKey.Builder keyBuilder = accessor.keyBuilder();
-    accessor.updateProperty(keyBuilder.customizedStateConfig(),
-        customizedStateConfigFromBuilder);
+    if(!accessor.updateProperty(keyBuilder.customizedStateConfig(),

Review comment:
       This pull only deals with exception in group commit. How about the zkclient closed issue in callbackhandler? 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] kaisun2000 commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
kaisun2000 commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500597479



##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -139,14 +142,22 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
           success = false;
           while (++retry <= MAX_RETRY && !success) {
             if (removeIfEmpty && merged.getMapFields().isEmpty()) {
-              success = accessor.remove(mergedKey, options);
+              try {
+                success = accessor.remove(mergedKey, options);
+              } catch (Exception e) {
+                success = false;

Review comment:
       Let us log this exception here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] lei-xia commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
lei-xia commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500498280



##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -112,6 +112,9 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
             merged = accessor.get(mergedKey, null, options);
           } catch (ZkNoNodeException e) {
             // OK.
+          } catch (Exception e) {

Review comment:
       Can you search all existing use cases (no related to customized state) and make sure there is no assumption on old behavior?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] zhangmeng916 commented on a change in pull request #1441: Catch exception in group commit

Posted by GitBox <gi...@apache.org>.
zhangmeng916 commented on a change in pull request #1441:
URL: https://github.com/apache/helix/pull/1441#discussion_r500586335



##########
File path: helix-core/src/main/java/org/apache/helix/GroupCommit.java
##########
@@ -112,6 +112,9 @@ public boolean commit(BaseDataAccessor<ZNRecord> accessor, int options, String k
             merged = accessor.get(mergedKey, null, options);
           } catch (ZkNoNodeException e) {
             // OK.
+          } catch (Exception e) {

Review comment:
       Done. Actually no impact on other function.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org