hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [3/3] hbase git commit: HBASE-20322 CME in StoreScanner causes region server crash
Date Tue, 03 Apr 2018 18:41:17 GMT
HBASE-20322 CME in StoreScanner causes region server crash

Signed-off-by: Andrew Purtell <apurtell@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 <thiruvel@oath.com>
Authored: Fri Mar 30 13:21:26 2018 -0700
Committer: Andrew Purtell <apurtell@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;


Mime
View raw message