helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jiajunw...@apache.org
Subject [helix] branch master updated: Catch exception in group commit (#1441)
Date Tue, 06 Oct 2020 21:58:50 GMT
This is an automated email from the ASF dual-hosted git repository.

jiajunwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/master by this push:
     new 78815f9  Catch exception in group commit (#1441)
78815f9 is described below

commit 78815f9b8bec31f2c3e7a5a116d0bbf976e758e3
Author: Meng Zhang <mnzhang@linkedin.com>
AuthorDate: Tue Oct 6 14:58:37 2020 -0700

    Catch exception in group commit (#1441)
    
    Catch exception in group commit.
---
 .../src/main/java/org/apache/helix/GroupCommit.java     | 17 ++++++++++++++---
 .../java/org/apache/helix/manager/zk/ZKHelixAdmin.java  |  7 +++++--
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/helix-core/src/main/java/org/apache/helix/GroupCommit.java b/helix-core/src/main/java/org/apache/helix/GroupCommit.java
index 38b6c31..6718e5d 100644
--- a/helix-core/src/main/java/org/apache/helix/GroupCommit.java
+++ b/helix-core/src/main/java/org/apache/helix/GroupCommit.java
@@ -25,8 +25,8 @@ import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
-import org.apache.helix.zookeeper.zkclient.exception.ZkNoNodeException;
 import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.helix.zookeeper.zkclient.exception.ZkNoNodeException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -112,6 +112,9 @@ public class GroupCommit {
             merged = accessor.get(mergedKey, null, options);
           } catch (ZkNoNodeException e) {
             // OK.
+          } catch (Exception e) {
+            LOG.error("Fail to get " + mergedKey + " from ZK", e);
+            return false;
           }
 
           /**
@@ -139,14 +142,22 @@ public class GroupCommit {
           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;
+              }
               if (!success) {
                 LOG.error("Fails to update " + mergedKey + " to ZK, retry it! ");
               }
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
index 8129b6c..1267161 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
@@ -1315,8 +1315,11 @@ public class ZKHelixAdmin implements HelixAdmin {
     ZKHelixDataAccessor accessor =
         new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkClient));
     PropertyKey.Builder keyBuilder = accessor.keyBuilder();
-    accessor.updateProperty(keyBuilder.customizedStateConfig(),
-        customizedStateConfigFromBuilder);
+    if(!accessor.updateProperty(keyBuilder.customizedStateConfig(),
+        customizedStateConfigFromBuilder)) {
+      throw new HelixException(
+          "Failed to add customized state config type " + type + " to cluster" + clusterName);
+    }
   }
 
 


Mime
View raw message