You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2015/08/06 11:18:59 UTC

[1/2] hbase git commit: Revert "HBASE-14178 regionserver blocks because of waiting for offsetLock"

Repository: hbase
Updated Branches:
  refs/heads/branch-1 fe9de40e6 -> 5c0c389b7


Revert "HBASE-14178 regionserver blocks because of waiting for offsetLock"

This reverts commit fe9de40e6c16b6e030a89a759fa278f0e27722aa.


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

Branch: refs/heads/branch-1
Commit: 4623c843c137888d606578ed1bc579272a5ab2c2
Parents: fe9de40
Author: zhangduo <zh...@apache.org>
Authored: Thu Aug 6 17:10:59 2015 +0800
Committer: zhangduo <zh...@apache.org>
Committed: Thu Aug 6 17:10:59 2015 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/io/hfile/CacheConfig.java      | 42 --------------------
 .../hadoop/hbase/io/hfile/HFileReaderV2.java    | 18 ++++-----
 2 files changed, 9 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/4623c843/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
index 26eb1da..0ed3cbd 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
@@ -431,48 +431,6 @@ public class CacheConfig {
     return isBlockCacheEnabled() && this.prefetchOnOpen;
   }
 
-  /**
-   * Return true if we may find this type of block in block cache.
-   * <p/>
-   * TODO: today {@code family.isBlockCacheEnabled()} only means {@code cacheDataOnRead}, so here we
-   * consider lots of other configurations such as {@code cacheDataOnWrite}. We should fix this in
-   * the future, {@code cacheDataOnWrite} should honor the CF level {@code isBlockCacheEnabled}
-   * configuration.
-   */
-  public boolean shouldReadBlockFromCache(BlockType blockType) {
-    if (!isBlockCacheEnabled()) {
-      return false;
-    }
-    if (cacheDataOnRead) {
-      return true;
-    }
-    if (prefetchOnOpen) {
-      return true;
-    }
-    if (cacheDataOnWrite) {
-      return true;
-    }
-    if (blockType == null) {
-      return true;
-    }
-    if (blockType.getCategory() == BlockCategory.BLOOM ||
-            blockType.getCategory() == BlockCategory.INDEX) {
-      return true;
-    }
-    return false;
-  }
-
-  /**
-   * If we make sure the block could not be cached, we will not acquire the lock
-   * otherwise we will acquire lock
-   */
-  public boolean shouldLockOnCacheMiss(BlockType blockType) {
-    if (blockType == null) {
-      return true;
-    }
-    return shouldCacheBlockOnRead(blockType.getCategory());
-  }
-
   @Override
   public String toString() {
     if (!isBlockCacheEnabled()) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/4623c843/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java
index 67aa922..4790ee9 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java
@@ -393,11 +393,12 @@ public class HFileReaderV2 extends AbstractHFileReader {
     TraceScope traceScope = Trace.startSpan("HFileReaderV2.readBlock");
     try {
       while (true) {
+        if (useLock) {
+          lockEntry = offsetLock.getLockEntry(dataBlockOffset);
+        }
+
         // Check cache for block. If found return.
         if (cacheConf.isBlockCacheEnabled()) {
-          if (useLock) {
-            lockEntry = offsetLock.getLockEntry(dataBlockOffset);
-          }
           // Try and get the block from the block cache. If the useLock variable is true then this
           // is the second time through the loop and it should not be counted as a block cache miss.
           HFileBlock cachedBlock = getCachedBlock(cacheKey, cacheBlock, useLock, isCompaction,
@@ -422,14 +423,13 @@ public class HFileReaderV2 extends AbstractHFileReader {
             // Cache-hit. Return!
             return cachedBlock;
           }
-          if (!useLock && cacheBlock && cacheConf.shouldLockOnCacheMiss(expectedBlockType)) {
-            // check cache again with lock
-            useLock = true;
-            continue;
-          }
           // Carry on, please load.
         }
-
+        if (!useLock) {
+          // check cache again with lock
+          useLock = true;
+          continue;
+        }
         if (Trace.isTracing()) {
           traceScope.getSpan().addTimelineAnnotation("blockCacheMiss");
         }


[2/2] hbase git commit: HBASE-14178 regionserver blocks because of waiting for offsetLock

Posted by zh...@apache.org.
HBASE-14178 regionserver blocks because of waiting for offsetLock

Signed-off-by: zhangduo <zh...@apache.org>


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

Branch: refs/heads/branch-1
Commit: 5c0c389b7a1b32a045e4bc1557b96a56291ab2ab
Parents: 4623c84
Author: chenheng <ch...@fenbi.com>
Authored: Thu Aug 6 16:42:34 2015 +0800
Committer: zhangduo <zh...@apache.org>
Committed: Thu Aug 6 17:17:52 2015 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/io/hfile/CacheConfig.java      | 42 ++++++++++++++++++++
 .../hadoop/hbase/io/hfile/HFileReaderV2.java    | 20 +++++-----
 2 files changed, 52 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/5c0c389b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
index 0ed3cbd..26eb1da 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
@@ -431,6 +431,48 @@ public class CacheConfig {
     return isBlockCacheEnabled() && this.prefetchOnOpen;
   }
 
+  /**
+   * Return true if we may find this type of block in block cache.
+   * <p/>
+   * TODO: today {@code family.isBlockCacheEnabled()} only means {@code cacheDataOnRead}, so here we
+   * consider lots of other configurations such as {@code cacheDataOnWrite}. We should fix this in
+   * the future, {@code cacheDataOnWrite} should honor the CF level {@code isBlockCacheEnabled}
+   * configuration.
+   */
+  public boolean shouldReadBlockFromCache(BlockType blockType) {
+    if (!isBlockCacheEnabled()) {
+      return false;
+    }
+    if (cacheDataOnRead) {
+      return true;
+    }
+    if (prefetchOnOpen) {
+      return true;
+    }
+    if (cacheDataOnWrite) {
+      return true;
+    }
+    if (blockType == null) {
+      return true;
+    }
+    if (blockType.getCategory() == BlockCategory.BLOOM ||
+            blockType.getCategory() == BlockCategory.INDEX) {
+      return true;
+    }
+    return false;
+  }
+
+  /**
+   * If we make sure the block could not be cached, we will not acquire the lock
+   * otherwise we will acquire lock
+   */
+  public boolean shouldLockOnCacheMiss(BlockType blockType) {
+    if (blockType == null) {
+      return true;
+    }
+    return shouldCacheBlockOnRead(blockType.getCategory());
+  }
+
   @Override
   public String toString() {
     if (!isBlockCacheEnabled()) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/5c0c389b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java
index 4790ee9..e1a0e6d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java
@@ -393,12 +393,11 @@ public class HFileReaderV2 extends AbstractHFileReader {
     TraceScope traceScope = Trace.startSpan("HFileReaderV2.readBlock");
     try {
       while (true) {
-        if (useLock) {
-          lockEntry = offsetLock.getLockEntry(dataBlockOffset);
-        }
-
         // Check cache for block. If found return.
-        if (cacheConf.isBlockCacheEnabled()) {
+        if (cacheConf.shouldReadBlockFromCache(expectedBlockType)) {
+          if (useLock) {
+            lockEntry = offsetLock.getLockEntry(dataBlockOffset);
+          }
           // Try and get the block from the block cache. If the useLock variable is true then this
           // is the second time through the loop and it should not be counted as a block cache miss.
           HFileBlock cachedBlock = getCachedBlock(cacheKey, cacheBlock, useLock, isCompaction,
@@ -423,13 +422,14 @@ public class HFileReaderV2 extends AbstractHFileReader {
             // Cache-hit. Return!
             return cachedBlock;
           }
+          if (!useLock && cacheBlock && cacheConf.shouldLockOnCacheMiss(expectedBlockType)) {
+            // check cache again with lock
+            useLock = true;
+            continue;
+          }
           // Carry on, please load.
         }
-        if (!useLock) {
-          // check cache again with lock
-          useLock = true;
-          continue;
-        }
+
         if (Trace.isTracing()) {
           traceScope.getSpan().addTimelineAnnotation("blockCacheMiss");
         }