You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2018/04/03 18:41:17 UTC

[3/3] hbase git commit: HBASE-20322 CME in StoreScanner causes region server crash

HBASE-20322 CME in StoreScanner causes region server crash

Signed-off-by: Andrew Purtell <ap...@apache.org>


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

Branch: refs/heads/branch-1
Commit: 875a12de054e8867fc5f70f470cf17251e862ee3
Parents: 18c54b0
Author: Thiruvel Thirumoolan <th...@oath.com>
Authored: Fri Mar 30 13:21:26 2018 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Mon Apr 2 19:36:16 2018 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/regionserver/StoreScanner.java | 35 +++++++++++++++-----
 1 file changed, 26 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/875a12de/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
index bb761ba..0280906 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java
@@ -462,17 +462,29 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
 
   @Override
   public void close() {
-    if (this.closing) return;
-    this.closing = true;
-    clearAndClose(scannersForDelayedClose);
-    clearAndClose(memStoreScannersAfterFlush);
-    // clear them at any case. In case scanner.next() was never called
-    // and there were some lease expiry we need to close all the scanners
-    // on the flushed files which are open
-    clearAndClose(flushedstoreFileScanners);
+    if (this.closing) {
+      return;
+    }
+    // Lets remove from observers as early as possible
     // Under test, we dont have a this.store
-    if (this.store != null)
+    if (this.store != null) {
       this.store.deleteChangedReaderObserver(this);
+    }
+    // There is a race condition between close() and updateReaders(), during region flush. So,
+    // even though its just close, we will still acquire the flush lock, as a
+    // ConcurrentModificationException will abort the regionserver.
+    flushLock.lock();
+    try {
+      this.closing = true;
+      clearAndClose(scannersForDelayedClose);
+      clearAndClose(memStoreScannersAfterFlush);
+      // clear them at any case. In case scanner.next() was never called
+      // and there were some lease expiry we need to close all the scanners
+      // on the flushed files which are open
+      clearAndClose(flushedstoreFileScanners);
+    } finally {
+      flushLock.unlock();
+    }
     if (this.heap != null)
       this.heap.close();
     this.heap = null; // CLOSED!
@@ -845,6 +857,11 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner
     }
     flushLock.lock();
     try {
+      if (this.closing) {
+        // Lets close scanners created by caller, since close() won't notice this.
+        clearAndClose(memStoreScanners);
+        return;
+      }
       flushed = true;
       final boolean isCompaction = false;
       boolean usePread = get || scanUsePread;