You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2014/06/09 21:10:15 UTC

git commit: ACCUMULO-2862 stop re-throwing CompactionInteruptedException, wrote a test to verify that splits interrupt major compactions

Repository: accumulo
Updated Branches:
  refs/heads/master 13d20941b -> 3f6c9e533


ACCUMULO-2862 stop re-throwing CompactionInteruptedException, wrote a test to verify that splits interrupt major compactions


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/3f6c9e53
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/3f6c9e53
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/3f6c9e53

Branch: refs/heads/master
Commit: 3f6c9e53371d1967ad5a1d896e08509bdff9405d
Parents: 13d2094
Author: Eric C. Newton <er...@gmail.com>
Authored: Mon Jun 9 15:08:28 2014 -0400
Committer: Eric C. Newton <er...@gmail.com>
Committed: Mon Jun 9 15:08:28 2014 -0400

----------------------------------------------------------------------
 .../apache/accumulo/tserver/InMemoryMap.java    |  4 +-
 .../apache/accumulo/tserver/tablet/Tablet.java  |  4 +-
 .../accumulo/test/SplitCancelsMajCIT.java       | 83 ++++++++++++++++++++
 3 files changed, 87 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/3f6c9e53/server/tserver/src/main/java/org/apache/accumulo/tserver/InMemoryMap.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/InMemoryMap.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/InMemoryMap.java
index 3c9c32c..7c7145b 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/InMemoryMap.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/InMemoryMap.java
@@ -499,7 +499,9 @@ public class InMemoryMap {
     return map.iterator(startKey);
   }
   
-  public long getNumEntries() {
+  public synchronized long getNumEntries() {
+    if (map == null)
+      return 0;
     return map.size();
   }
   

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3f6c9e53/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
index 38fdda6..8d800d8 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
@@ -1319,7 +1319,7 @@ public class Tablet implements TabletCommitter {
 
       // determines if inserts and queries can still continue while minor compacting
       if (disableWrites) {
-        closeState = CloseState.CLOSING;
+        closeState = CloseState.CLOSED;
       }
 
       // wait for major compactions to finish, setting closing to
@@ -1988,11 +1988,9 @@ public class Tablet implements TabletCommitter {
         success = true;
       } catch (CompactionCanceledException mcce) {
         log.debug("Major compaction canceled, extent = " + getExtent());
-        throw new RuntimeException(mcce);
       } catch (Throwable t) {
         log.error("MajC Failed, extent = " + getExtent());
         log.error("MajC Failed, message = " + (t.getMessage() == null ? t.getClass().getName() : t.getMessage()), t);
-        throw new RuntimeException(t);
       } finally {
         // ensure we always reset boolean, even
         // when an exception is thrown

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3f6c9e53/test/src/test/java/org/apache/accumulo/test/SplitCancelsMajCIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/SplitCancelsMajCIT.java b/test/src/test/java/org/apache/accumulo/test/SplitCancelsMajCIT.java
new file mode 100644
index 0000000..609e1af
--- /dev/null
+++ b/test/src/test/java/org/apache/accumulo/test/SplitCancelsMajCIT.java
@@ -0,0 +1,83 @@
+/*
+ * 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 static org.junit.Assert.assertTrue;
+
+import java.util.EnumSet;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.Connector;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+import org.apache.accumulo.core.util.UtilWaitThread;
+import org.apache.accumulo.test.functional.SimpleMacIT;
+import org.apache.accumulo.test.functional.SlowIterator;
+import org.apache.hadoop.io.Text;
+import org.junit.Test;
+
+// ACCUMULO-2862
+public class SplitCancelsMajCIT extends SimpleMacIT{
+  
+  @Test(timeout = 2 * 60 * 1000)
+  public void test() throws Exception {
+    final String tableName = getUniqueNames(1)[0];
+    final Connector c = getConnector();
+    c.tableOperations().create(tableName);
+    // majc should take 100 * .5 secs
+    IteratorSetting it = new IteratorSetting(100, SlowIterator.class);
+    SlowIterator.setSleepTime(it, 500);
+    c.tableOperations().attachIterator(tableName, it, EnumSet.of(IteratorScope.majc));
+    BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+    for (int i = 0; i < 100; i++) {
+      Mutation m = new Mutation("" + i);
+      m.put("", "", new Value());
+      bw.addMutation(m);
+    }
+    bw.flush();
+    // start majc
+    final AtomicReference<Exception> ex = new AtomicReference<Exception>();
+    Thread thread = new Thread() {
+      public void run() {
+        try {
+          c.tableOperations().compact(tableName, null, null, true, true);
+        } catch (Exception e) {
+          ex.set(e);
+        }
+      }
+    };
+    thread.start();
+
+    long now = System.currentTimeMillis();
+    UtilWaitThread.sleep(10 * 1000);    
+    // split the table, interrupts the compaction
+    SortedSet<Text> partitionKeys = new TreeSet<Text>();
+    partitionKeys.add(new Text("10"));
+    c.tableOperations().addSplits(tableName, partitionKeys);
+    thread.join();
+    // wait for the restarted compaction
+    assertTrue(System.currentTimeMillis() - now > 59 * 1000);
+    if (ex.get() != null)
+      throw ex.get();
+  }
+}