hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r1539910 - in /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase: catalog/MetaEditor.java master/snapshot/RestoreSnapshotHandler.java
Date Fri, 08 Nov 2013 03:10:01 GMT
Author: enis
Date: Fri Nov  8 03:09:58 2013
New Revision: 1539910

URL: http://svn.apache.org/r1539910
Log:
HBASE-9906 Restore snapshot fails to restore the meta edits sporadically

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java?rev=1539910&r1=1539909&r2=1539910&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java Fri
Nov  8 03:09:58 2013
@@ -36,6 +36,7 @@ import org.apache.hadoop.hbase.client.Pu
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.PairOfSameType;
+import org.apache.hadoop.hbase.util.Threads;
 import org.apache.hadoop.hbase.util.Writables;
 
 /**
@@ -357,6 +358,24 @@ public class MetaEditor {
     }
   }
 
+  /**
+   * Overwrites the specified regions from hbase:meta
+   * @param catalogTracker
+   * @param regionInfos list of regions to be added to META
+   * @throws IOException
+   */
+  public static void overwriteRegions(CatalogTracker catalogTracker,
+      List<HRegionInfo> regionInfos) throws IOException {
+    deleteRegions(catalogTracker, regionInfos);
+    // Why sleep? This is the easiest way to ensure that the previous deletes does not
+    // eclipse the following puts, that might happen in the same ts from the server.
+    // See HBASE-9906, and HBASE-9879. Once either HBASE-9879, HBASE-8770 is fixed,
+    // or HBASE-9905 is fixed and meta uses seqIds, we do not need the sleep.
+    Threads.sleep(20);
+    addRegionsToMeta(catalogTracker, regionInfos);
+    LOG.info("Overwritten " + regionInfos);
+  }
+
   public static HRegionInfo getHRegionInfo(
       Result data) throws IOException {
     byte [] bytes =

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java?rev=1539910&r1=1539909&r2=1539910&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java
Fri Nov  8 03:09:58 2013
@@ -141,7 +141,6 @@ public class RestoreSnapshotHandler exte
       // that are not correct after the restore.
       List<HRegionInfo> hrisToRemove = new LinkedList<HRegionInfo>();
       if (metaChanges.hasRegionsToRemove()) hrisToRemove.addAll(metaChanges.getRegionsToRemove());
-      if (metaChanges.hasRegionsToRestore()) hrisToRemove.addAll(metaChanges.getRegionsToRestore());
       MetaEditor.deleteRegions(catalogTracker, hrisToRemove);
 
       // 4.2 Add the new set of regions to META
@@ -152,8 +151,8 @@ public class RestoreSnapshotHandler exte
       // in the snapshot folder.
       hris.clear();
       if (metaChanges.hasRegionsToAdd()) hris.addAll(metaChanges.getRegionsToAdd());
-      if (metaChanges.hasRegionsToRestore()) hris.addAll(metaChanges.getRegionsToRestore());
       MetaEditor.addRegionsToMeta(catalogTracker, hris);
+      MetaEditor.overwriteRegions(catalogTracker, metaChanges.getRegionsToRestore());
       metaChanges.updateMetaParentRegions(catalogTracker, hris);
 
       // At this point the restore is complete. Next step is enabling the table.



Mime
View raw message