From 45ef1dad5e380e2d4fd4774aa90affed28e727fb Mon Sep 17 00:00:00 2001 From: Mike Miller Date: Fri, 15 Feb 2019 17:58:17 -0500 Subject: [PATCH] Fix race condition in Tables. Closes #768 --- .../accumulo/core/clientImpl/Tables.java | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/Tables.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/Tables.java index 1f393a3d344..209ace4d1bf 100644 --- a/core/src/main/java/org/apache/accumulo/core/clientImpl/Tables.java +++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/Tables.java @@ -51,8 +51,6 @@ public class Tables { // frequently private static Cache instanceToMapCache = CacheBuilder.newBuilder() .expireAfterAccess(10, TimeUnit.MINUTES).build(); - private static Cache instanceToZooCache = CacheBuilder.newBuilder() - .expireAfterAccess(10, TimeUnit.MINUTES).build(); static { SingletonManager.register(new SingletonService() { @@ -73,7 +71,6 @@ public synchronized void enable() { public synchronized void disable() { try { instanceToMapCache.invalidateAll(); - instanceToZooCache.invalidateAll(); } finally { enabled = false; } @@ -95,28 +92,14 @@ public static TableId getTableId(ClientContext context, String tableName) } } - /** - * Return the cached ZooCache for provided context. ZooCache is initially created with a watcher - * that will clear the TableMap cache for that instance when WatchedEvent occurs. - */ private static ZooCache getZooCache(final ClientContext context) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(TABLES_PERMISSION); } - final String uuid = context.getInstanceID(); - - try { - return instanceToZooCache.get(uuid, () -> { - final String zks = context.getZooKeepers(); - final int timeOut = context.getZooKeepersSessionTimeOut(); - return new ZooCacheFactory().getZooCache(zks, timeOut, - watchedEvent -> instanceToMapCache.invalidate(uuid)); - }); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } + return new ZooCacheFactory().getZooCache(context.getZooKeepers(), + context.getZooKeepersSessionTimeOut()); } /**