hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhang...@apache.org
Subject hbase git commit: HBASE-13970 NPE during compaction in trunk
Date Thu, 02 Jul 2015 13:37:18 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 272b025b2 -> 28a035000


HBASE-13970 NPE during compaction in trunk


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/28a03500
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/28a03500
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/28a03500

Branch: refs/heads/master
Commit: 28a035000f3cbf7c2b242d6dd9ba3bf84f4e2503
Parents: 272b025
Author: zhangduo <zhangduo@wandoujia.com>
Authored: Fri Jun 26 08:10:05 2015 +0800
Committer: zhangduo <zhangduo@wandoujia.com>
Committed: Thu Jul 2 21:36:11 2015 +0800

----------------------------------------------------------------------
 .../regionserver/compactions/Compactor.java     | 22 ++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/28a03500/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/Compactor.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/Compactor.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/Compactor.java
index 26fef53..78a5cac 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/Compactor.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/Compactor.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -222,6 +223,24 @@ public abstract class Compactor {
   }
 
   /**
+   * Used to prevent compaction name conflict when multiple compactions running parallel
on the
+   * same store.
+   */
+  private static final AtomicInteger NAME_COUNTER = new AtomicInteger(0);
+
+  private String generateCompactionName() {
+    int counter;
+    for (;;) {
+      counter = NAME_COUNTER.get();
+      int next = counter == Integer.MAX_VALUE ? 0 : counter + 1;
+      if (NAME_COUNTER.compareAndSet(counter, next)) {
+        break;
+      }
+    }
+    return store.getRegionInfo().getRegionNameAsString() + "#"
+        + store.getFamily().getNameAsString() + "#" + counter;
+  }
+  /**
    * Performs the compaction.
    * @param scanner Where to read from.
    * @param writer Where to write to.
@@ -242,8 +261,7 @@ public abstract class Compactor {
     if (LOG.isDebugEnabled()) {
       lastMillis = EnvironmentEdgeManager.currentTime();
     }
-    String compactionName =
-        store.getRegionInfo().getRegionNameAsString() + "#" + store.getFamily().getNameAsString();
+    String compactionName = generateCompactionName();
     long now = 0;
     boolean hasMore;
     ScannerContext scannerContext =


Mime
View raw message