HBASE-24211: Create table is slow in large cluster when AccessController is enabled. (#1577)

Signed-off-by: Viraj Jasani <vjasani@apache.org>
Signed-off-by: Pankaj <pankajkumar@apache.org>
This commit is contained in:
Mohammad Arshad 2020-04-25 17:48:47 +05:30 committed by GitHub
parent a7a4f61040
commit 9fc8263ca4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 21 deletions

View File

@ -29,6 +29,7 @@ import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.Iterator;
@ -801,6 +802,10 @@ public class ZKUtil {
if (nodes != null) {
List<NodeAndData> newNodes = new ArrayList<NodeAndData>();
for (String node : nodes) {
if (Thread.interrupted()) {
// Partial data should not be processed. Cancel processing by sending empty list.
return Collections.emptyList();
}
String nodePath = ZKUtil.joinZNode(baseNode, node);
byte[] data = ZKUtil.getDataAndWatch(zkw, nodePath);
newNodes.add(new NodeAndData(nodePath, data));

View File

@ -184,30 +184,32 @@ public class ZKPermissionWatcher extends ZooKeeperListener implements Closeable
public void nodeChildrenChanged(final String path) {
waitUntilStarted();
if (path.equals(aclZNode)) {
try {
final List<ZKUtil.NodeAndData> 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(new Runnable() {
@Override
public void run() {
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(new Runnable() {
@Override public void run() {
try {
final List<ZKUtil.NodeAndData> 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);
}
}
});
}
}