Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4264A17256 for ; Fri, 29 May 2015 01:32:49 +0000 (UTC) Received: (qmail 64570 invoked by uid 500); 29 May 2015 01:32:48 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 64508 invoked by uid 500); 29 May 2015 01:32:48 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 64357 invoked by uid 99); 29 May 2015 01:32:48 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 May 2015 01:32:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 72114E1105; Fri, 29 May 2015 01:32:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: elserj@apache.org To: commits@accumulo.apache.org Date: Fri, 29 May 2015 01:32:48 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/9] accumulo git commit: ACCUMULO-3859 Ensure multiple TableConfiguration instances are not created. Repository: accumulo Updated Branches: refs/heads/1.6 6f7bf39b7 -> 55a9c8a99 refs/heads/1.7 44cd47035 -> bb73e90aa refs/heads/master 633138205 -> 302617d04 ACCUMULO-3859 Ensure multiple TableConfiguration instances are not created. If an instance of a TableConfiguration is cached which isn't the same instance held by a Tablet, this will result in the Tablet never receiving updates for constraints and more. Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/f122beb1 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/f122beb1 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/f122beb1 Branch: refs/heads/1.6 Commit: f122beb129913a98f3bd32882ef34c8104c35f96 Parents: 6f7bf39 Author: Josh Elser Authored: Thu May 28 13:28:13 2015 -0400 Committer: Josh Elser Committed: Thu May 28 21:30:38 2015 -0400 ---------------------------------------------------------------------- .../server/conf/ServerConfigurationFactory.java | 31 +++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/f122beb1/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java index 96ff5d6..7981f3b 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java @@ -34,14 +34,9 @@ import org.apache.accumulo.fate.zookeeper.ZooCacheFactory; */ public class ServerConfigurationFactory { - private static final Map> tableConfigs; - private static final Map> namespaceConfigs; - private static final Map> tableParentConfigs; - static { - tableConfigs = new HashMap>(1); - namespaceConfigs = new HashMap>(1); - tableParentConfigs = new HashMap>(1); - } + private static final Map> tableConfigs = new HashMap>(1); + private static final Map> namespaceConfigs = new HashMap>(1); + private static final Map> tableParentConfigs = new HashMap>(1); private static void addInstanceToCaches(String iid) { synchronized (tableConfigs) { @@ -152,13 +147,27 @@ public class ServerConfigurationFactory { synchronized (tableConfigs) { conf = tableConfigs.get(instanceID).get(tableId); } - // can't hold the lock during the construction and validation of the config, - // which may result in creating multiple objects for the same id, but that's ok. + + // Can't hold the lock during the construction and validation of the config, + // which would result in creating multiple objects for the same id. + // + // ACCUMULO-3859 We _cannot_ all multiple instances to be created for a table. If the TableConfiguration + // instance a Tablet holds is not the same as the one cached here, any ConfigurationObservers that + // Tablet sets will never see updates from ZooKeeper which means that things like constraints and + // default visibility labels will never be updated in a Tablet until it is reloaded. if (conf == null && Tables.exists(instance, tableId)) { conf = new TableConfiguration(instance.getInstanceID(), tableId, getNamespaceConfigurationForTable(tableId)); ConfigSanityCheck.validate(conf); synchronized (tableConfigs) { - tableConfigs.get(instanceID).put(tableId, conf); + Map configs = tableConfigs.get(instanceID); + TableConfiguration existingConf = configs.get(tableId); + if (null == existingConf) { + // Configuration doesn't exist yet + configs.put(tableId, conf); + } else { + // Someone beat us to the punch, reuse their instance instead of replacing it + conf = existingConf; + } } } return conf;