Index: src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java (revision 1212209) +++ src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java (working copy) @@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; +import org.apache.hadoop.hbase.ipc.HRegionInterface; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Writables; @@ -163,16 +164,18 @@ } /** - * Offline parent in meta. - * Used when splitting. + * Offline parent in meta. Used when splitting. + * * @param catalogTracker * @param parent * @param a Split daughter region A * @param b Split daughter region B + * @return false if MetaServer Connection is not OK, true if successfully + * update meta * @throws NotAllMetaRegionsOnlineException * @throws IOException */ - public static void offlineParentInMeta(CatalogTracker catalogTracker, + public static boolean offlineParentInMeta(CatalogTracker catalogTracker, HRegionInfo parent, final HRegionInfo a, final HRegionInfo b) throws NotAllMetaRegionsOnlineException, IOException { HRegionInfo copyOfParent = new HRegionInfo(parent); @@ -184,9 +187,17 @@ Writables.getBytes(a)); put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER, Writables.getBytes(b)); - putToMetaTable(catalogTracker, put); + HRegionInterface metaServer; + try { + metaServer = catalogTracker.waitForMetaServerConnectionDefault(); + } catch (Exception e) { + LOG.info("Failed waiting for meta server connection", e); + return false; + } + metaServer.put(CatalogTracker.META_REGION_NAME, put); LOG.info("Offlined parent region " + parent.getRegionNameAsString() + " in META"); + return true; } public static void addDaughter(final CatalogTracker catalogTracker, Index: src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java (revision 1212209) +++ src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java (working copy) @@ -41,8 +41,8 @@ import org.apache.hadoop.hbase.Server; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.catalog.MetaEditor; +import org.apache.hadoop.hbase.executor.EventHandler.EventType; import org.apache.hadoop.hbase.executor.RegionTransitionData; -import org.apache.hadoop.hbase.executor.EventHandler.EventType; import org.apache.hadoop.hbase.io.Reference.Range; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.CancelableProgressable; @@ -285,28 +285,39 @@ this.journal.add(JournalEntry.STARTED_REGION_B_CREATION); HRegion b = createDaughterRegion(this.hri_b, this.parent.rsServices); - // This is the point of no return. Adding subsequent edits to .META. as we - // do below when we do the daughter opens adding each to .META. can fail in - // various interesting ways the most interesting of which is a timeout - // BUT the edits all go through (See HBASE-3872). IF we reach the PONR - // then subsequent failures need to crash out this regionserver; the - // server shutdown processing should be able to fix-up the incomplete split. - // The offlined parent will have the daughters as extra columns. If - // we leave the daughter regions in place and do not remove them when we - // crash out, then they will have their references to the parent in place - // still and the server shutdown fixup of .META. will point to these - // regions. - // We should add PONR JournalEntry before offlineParentInMeta,so even if - // OfflineParentInMeta timeout,this will cause regionserver exit,and then - // master ServerShutdownHandler will fix daughter & avoid data loss. (See - // HBase-4562). - this.journal.add(JournalEntry.PONR); + // Edit parent in meta. Offlines parent region and adds splita and splitb. + boolean toPONR = true; + try { + if (!testing) { + toPONR = MetaEditor.offlineParentInMeta(server.getCatalogTracker(), + this.parent.getRegionInfo(), a.getRegionInfo(), b.getRegionInfo()); + } + } finally { + // This is the point of no return. Adding subsequent edits to .META. as we + // do below when we do the daughter opens adding each to .META. can fail + // in + // various interesting ways the most interesting of which is a timeout + // BUT the edits all go through (See HBASE-3872). IF we reach the PONR + // then subsequent failures need to crash out this regionserver; the + // server shutdown processing should be able to fix-up the incomplete + // split. + // The offlined parent will have the daughters as extra columns. If + // we leave the daughter regions in place and do not remove them when we + // crash out, then they will have their references to the parent in place + // still and the server shutdown fixup of .META. will point to these + // regions. + // We should add PONR JournalEntry before offlineParentInMeta,so even if + // OfflineParentInMeta timeout,this will cause regionserver exit,and then + // master ServerShutdownHandler will fix daughter & avoid data loss. (See + // HBase-4562). + if (toPONR) { + this.journal.add(JournalEntry.PONR); + } else { + throw new IOException( + "Failed waiting for meta server connection when doing offlineParentInMeta()"); + } + } - // Edit parent in meta. Offlines parent region and adds splita and splitb. - if (!testing) { - MetaEditor.offlineParentInMeta(server.getCatalogTracker(), - this.parent.getRegionInfo(), a.getRegionInfo(), b.getRegionInfo()); - } return new PairOfSameType(a, b); }