accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [3/3] git commit: ACCUMULO-3096 stopped retrying metadata updates on contraint violations
Date Thu, 04 Sep 2014 15:58:14 GMT
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 <kturner@apache.org>
Authored: Thu Sep 4 11:54:36 2014 -0400
Committer: Keith Turner <kturner@apache.org>
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();
+      }
+    }
+  }
+}


Mime
View raw message