You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ra...@apache.org on 2012/01/12 18:37:39 UTC

svn commit: r1230658 - in /hbase/branches/0.90: CHANGES.txt src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java

Author: ramkrishna
Date: Thu Jan 12 17:37:39 2012
New Revision: 1230658

URL: http://svn.apache.org/viewvc?rev=1230658&view=rev
Log:
HBASE-5168 Backport HBASE-5100 - Rollback of split could cause closed region to be opened again (Ram)

Modified:
    hbase/branches/0.90/CHANGES.txt
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1230658&r1=1230657&r2=1230658&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Thu Jan 12 17:37:39 2012
@@ -158,7 +158,8 @@ Release 0.90.5 - Dec 22, 2011
    HBASE-5157  Backport HBASE-4880- Region is on service before openRegionHandler 
                completes, may cause data loss (Ram)
    HBASE-5158  Backport HBASE-4878 - Master crash when splitting hlog may cause data loss (Ram)
-
+   HBASE-5168  Backport HBASE-5100 - Rollback of split could cause closed region to be opened again(Ram)
+ 
   NEW FEATURE
    HBASE-4377  [hbck] Offline rebuild .META. from fs data only
                (Jonathan Hsieh)

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java?rev=1230658&r1=1230657&r2=1230658&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java Thu Jan 12 17:37:39 2012
@@ -189,6 +189,8 @@ class SplitTransaction {
     return rid;
   }
 
+  private static IOException closedByOtherException = new IOException(
+      "Failed to close region: already closed by another thread");
   /**
    * Run the transaction.
    * @param server Hosting server instance.  Can be null when testing (won't try
@@ -219,20 +221,28 @@ class SplitTransaction {
     this.journal.add(JournalEntry.CREATE_SPLIT_DIR);
 
     List<StoreFile> hstoreFilesToSplit = null;
+    Exception exceptionToThrow = null;
     try{
       hstoreFilesToSplit = this.parent.close(false);
-      if (hstoreFilesToSplit == null) {
-        // The region was closed by a concurrent thread.  We can't continue
-        // with the split, instead we must just abandon the split.  If we
-        // reopen or split this could cause problems because the region has
-        // probably already been moved to a different server, or is in the
-        // process of moving to a different server.
-        throw new IOException("Failed to close region: already closed by " +
-          "another thread");
-      }
-    } finally {
+    } catch (Exception e) {
+      exceptionToThrow = e;
+    }
+    if (exceptionToThrow == null && hstoreFilesToSplit == null) {
+      // The region was closed by a concurrent thread. We can't continue
+      // with the split, instead we must just abandon the split. If we
+      // reopen or split this could cause problems because the region has
+      // probably already been moved to a different server, or is in the
+      // process of moving to a different server.
+      exceptionToThrow = closedByOtherException;
+    }
+    if (exceptionToThrow != closedByOtherException) {
       this.journal.add(JournalEntry.CLOSED_PARENT_REGION);
     }
+    if (exceptionToThrow != null) {
+      if (exceptionToThrow instanceof IOException)
+        throw (IOException) exceptionToThrow;
+      throw new IOException(exceptionToThrow);
+    }
 
     if (!testing) {
       services.removeFromOnlineRegions(this.parent.getRegionInfo().getEncodedName());