You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2011/12/31 03:43:56 UTC

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

Author: tedyu
Date: Sat Dec 31 02:43:56 2011
New Revision: 1226028

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

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

Modified: hbase/branches/0.92/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1226028&r1=1226027&r2=1226028&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Sat Dec 31 02:43:56 2011
@@ -501,6 +501,7 @@ Release 0.92.0 - Unreleased
    HBASE-5077  SplitLogWorker fails to let go of a task, kills the RS
    HBASE-5096  Replication does not handle deletes correctly. (Lars H)
    HBASE-5103  Fix improper master znode deserialization (Jonathan Hsieh)
+   HBASE-5100  Rollback of split could cause closed region to be opened again (Chunhui)
 
   TESTS
    HBASE-4492  TestRollingRestart fails intermittently

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java?rev=1226028&r1=1226027&r2=1226028&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java (original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java Sat Dec 31 02:43:56 2011
@@ -200,6 +200,9 @@ public class SplitTransaction {
     return rid;
   }
 
+  private static IOException closedByOtherException = new IOException(
+      "Failed to close region: already closed by another thread");
+  
   /**
    * Prepare the regions and region files.
    * @param server Hosting server instance.  Can be null when testing (won't try
@@ -246,20 +249,27 @@ public 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());