From 66e90dece2b95bd2eb322b5a17ae180a735597da Mon Sep 17 00:00:00 2001 From: Mohammad Arshad Date: Sat, 25 Apr 2020 17:41:43 +0530 Subject: [PATCH] HBASE-24211: Create table is slow in large cluster when AccessController is enabled. (#1546) Signed-off-by: Viraj Jasani Signed-off-by: Pankaj --- .../security/access/ZKPermissionWatcher.java | 35 ++++++++++--------- .../apache/hadoop/hbase/zookeeper/ZKUtil.java | 4 +++ 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java index b410719cb4b..5ad0d7eba49 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/ZKPermissionWatcher.java @@ -185,25 +185,28 @@ public class ZKPermissionWatcher extends ZKListener implements Closeable { public void nodeChildrenChanged(final String path) { waitUntilStarted(); if (path.equals(aclZNode)) { - try { - final List nodeList = - ZKUtil.getChildDataAndWatchForNewChildren(watcher, aclZNode); - // preempt any existing nodeChildrenChanged event processing - if (childrenChangedFuture != null && !childrenChangedFuture.isDone()) { - boolean cancelled = childrenChangedFuture.cancel(true); - if (!cancelled) { - // task may have finished between our check and attempted cancel, this is fine. - if (! childrenChangedFuture.isDone()) { - LOG.warn("Could not cancel processing node children changed event, " + - "please file a JIRA and attach logs if possible."); - } + // preempt any existing nodeChildrenChanged event processing + if (childrenChangedFuture != null && !childrenChangedFuture.isDone()) { + boolean cancelled = childrenChangedFuture.cancel(true); + if (!cancelled) { + // task may have finished between our check and attempted cancel, this is fine. + if (!childrenChangedFuture.isDone()) { + LOG.warn("Could not cancel processing node children changed event, " + + "please file a JIRA and attach logs if possible."); } } - childrenChangedFuture = asyncProcessNodeUpdate(() -> refreshNodes(nodeList)); - } catch (KeeperException ke) { - LOG.error("Error reading data from zookeeper for path "+path, ke); - watcher.abort("ZooKeeper error get node children for path "+path, ke); } + childrenChangedFuture = asyncProcessNodeUpdate(() -> { + try { + final List nodeList = + ZKUtil.getChildDataAndWatchForNewChildren(watcher, aclZNode); + refreshNodes(nodeList); + } catch (KeeperException ke) { + String msg = "ZooKeeper error while reading node children data for path " + path; + LOG.error(msg, ke); + watcher.abort(msg, ke); + } + }); } } diff --git a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java index 3f0f93f6321..7aec7a18087 100644 --- a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java +++ b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java @@ -742,6 +742,10 @@ public final class ZKUtil { if (nodes != null) { List newNodes = new ArrayList<>(); for (String node : nodes) { + if (Thread.interrupted()) { + // Partial data should not be processed. Cancel processing by sending empty list. + return Collections.emptyList(); + } String nodePath = ZNodePaths.joinZNode(baseNode, node); byte[] data = ZKUtil.getDataAndWatch(zkw, nodePath); newNodes.add(new NodeAndData(nodePath, data));