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 27097118C2 for ; Thu, 4 Sep 2014 15:58:13 +0000 (UTC) Received: (qmail 65628 invoked by uid 500); 4 Sep 2014 15:58:13 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 65526 invoked by uid 500); 4 Sep 2014 15:58:13 -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 65420 invoked by uid 99); 4 Sep 2014 15:58:12 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Sep 2014 15:58:12 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B17A8A07D43; Thu, 4 Sep 2014 15:58:12 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kturner@apache.org To: commits@accumulo.apache.org Date: Thu, 04 Sep 2014 15:58:14 -0000 Message-Id: In-Reply-To: <146bc3422b9947e7a546b58e5eca4c99@git.apache.org> References: <146bc3422b9947e7a546b58e5eca4c99@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/3] git commit: ACCUMULO-3096 stopped retrying metadata updates on contraint violations ACCUMULO-3096 stopped retrying metadata updates on contraint violations Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/632c572b Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/632c572b Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/632c572b Branch: refs/heads/1.6.1-SNAPSHOT Commit: 632c572b211c6e152698436c4ef5759cad836e8b Parents: 2698dde Author: Keith Turner Authored: Thu Sep 4 11:54:36 2014 -0400 Committer: Keith Turner Committed: Thu Sep 4 11:54:36 2014 -0400 ---------------------------------------------------------------------- .../accumulo/core/client/impl/Writer.java | 5 ++ .../accumulo/server/util/MetadataTableUtil.java | 7 ++- .../accumulo/test/MetaConstraintRetryIT.java | 58 ++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/632c572b/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java b/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java index d6762e7..d58d1e4 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java @@ -95,6 +95,11 @@ public class Writer { } catch (NotServingTabletException e) { log.trace("Not serving tablet, server = " + tabLoc.tablet_location); TabletLocator.getLocator(instance, table).invalidateCache(tabLoc.tablet_extent); + } catch (ConstraintViolationException cve) { + log.error("error sending update to " + tabLoc.tablet_location + ": " + cve); + // probably do not need to invalidate cache, but it does not hurt + TabletLocator.getLocator(instance, table).invalidateCache(tabLoc.tablet_extent); + throw cve; } catch (TException e) { log.error("error sending update to " + tabLoc.tablet_location + ": " + e); TabletLocator.getLocator(instance, table).invalidateCache(tabLoc.tablet_extent); http://git-wip-us.apache.org/repos/asf/accumulo/blob/632c572b/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java index 463ca57..f978439 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java @@ -130,6 +130,10 @@ public class MetadataTableUtil { public static void update(Credentials credentials, ZooLock zooLock, Mutation m, KeyExtent extent) { Writer t = extent.isMeta() ? getRootTable(credentials) : getMetadataTable(credentials); + update(t, credentials, zooLock, m); + } + + public static void update(Writer t, Credentials credentials, ZooLock zooLock, Mutation m) { if (zooLock != null) putLockID(zooLock, m); while (true) { @@ -142,12 +146,13 @@ public class MetadataTableUtil { log.error(e, e); } catch (ConstraintViolationException e) { log.error(e, e); + // retrying when a CVE occurs is probably futile and can cause problems, see ACCUMULO-3096 + throw new RuntimeException(e); } catch (TableNotFoundException e) { log.error(e, e); } UtilWaitThread.sleep(1000); } - } public static void updateTabletFlushID(KeyExtent extent, long flushID, Credentials credentials, ZooLock zooLock) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/632c572b/test/src/test/java/org/apache/accumulo/test/MetaConstraintRetryIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/MetaConstraintRetryIT.java b/test/src/test/java/org/apache/accumulo/test/MetaConstraintRetryIT.java new file mode 100644 index 0000000..b5487ff --- /dev/null +++ b/test/src/test/java/org/apache/accumulo/test/MetaConstraintRetryIT.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.accumulo.test; + +import org.apache.accumulo.core.client.impl.Writer; +import org.apache.accumulo.core.client.security.tokens.PasswordToken; +import org.apache.accumulo.core.data.KeyExtent; +import org.apache.accumulo.core.data.Mutation; +import org.apache.accumulo.core.metadata.MetadataTable; +import org.apache.accumulo.core.security.Credentials; +import org.apache.accumulo.core.security.TablePermission; +import org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException; +import org.apache.accumulo.server.util.MetadataTableUtil; +import org.apache.accumulo.test.functional.SimpleMacIT; +import org.apache.hadoop.io.Text; +import org.junit.Test; + +public class MetaConstraintRetryIT extends SimpleMacIT { + + //a test for ACCUMULO-3096 + @Test(timeout = 30 * 1000, expected = ConstraintViolationException.class) + public void test() throws Exception { + + getConnector().securityOperations().grantTablePermission("root", MetadataTable.NAME, TablePermission.WRITE); + + Credentials credentials = new Credentials("root", new PasswordToken(ROOT_PASSWORD)); + Writer w = new Writer(super.getConnector().getInstance(), credentials, MetadataTable.ID); + KeyExtent extent = new KeyExtent(new Text("5"), null, null); + + + Mutation m = new Mutation(extent.getMetadataEntry()); + // unknown columns should cause contraint violation + m.put("badcolfam", "badcolqual", "3"); + + try { + MetadataTableUtil.update(w, credentials, null, m); + } catch (RuntimeException e) { + if (e.getCause().getClass().equals(ConstraintViolationException.class)) { + throw (ConstraintViolationException) e.getCause(); + } + } + } +}