Index: src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java (revision 1164349) +++ src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java (working copy) @@ -324,6 +324,14 @@ if (!FSUtils.rootRegionExists(fs, rd)) { bootstrap(rd, c); } + // Create META and ROOT tableInfo if required. + if (!FSUtils.tableInfoExists(fs, rd, "-ROOT-")) { + FSUtils.createTableDescriptor(HTableDescriptor.ROOT_TABLEDESC, this.conf); + } + if (!FSUtils.tableInfoExists(fs, rd, ".META.")) { + FSUtils.createTableDescriptor(HTableDescriptor.META_TABLEDESC, this.conf); + } + return rd; } Index: src/main/java/org/apache/hadoop/hbase/util/FSUtils.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (revision 1164349) +++ src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (working copy) @@ -490,6 +490,20 @@ return fs.exists(rootRegionDir); } + /** + * Checks if .tableinfo exists for given table + * + * @param fs file system + * @param rootdir root directory of HBase installation + * @param tableName name of table + * @return true if exists + * @throws IOException + */ + public static boolean tableInfoExists(FileSystem fs, Path rootdir, + String tableName) throws IOException { + Path tablePath = getTableInfoPath(rootdir, tableName); + return fs.exists(tablePath); + } /** * Compute HDFS blocks distribution of a given file, or a portion of the file Index: src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (revision 1165132) +++ src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (working copy) @@ -913,8 +913,18 @@ value, new HRegionInfo()); // possible we got a region of a different table... if (!Bytes.equals(regionInfo.getTableName(), tableName)) { - throw new TableNotFoundException( - "Table '" + Bytes.toString(tableName) + "' was not found."); + byte[] regionNameFromHRI = regionInfo.getRegionName(); + if (regionNameFromHRI != null && + regionNameFromHRI.length >= tableName.length+1 && + Bytes.compareTo(regionNameFromHRI, 0, tableName.length, + tableName, 0, tableName.length) == 0 && + // next byte should be ',' + regionNameFromHRI[tableName.length] == 0x2C) { + } else { + throw new TableNotFoundException( + "Table '" + Bytes.toString(tableName) + "' was not found, got: " + + Bytes.toString(regionInfo.getTableName()) + "."); + } } if (regionInfo.isSplit()) { throw new RegionOfflineException("the only available region for" +