Permalink
Browse files

HBASE-5466 Opening a table also opens the metatable and never closes it

               (Ashley Taylor)


git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1293047 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 268a7fe commit 75d4931d9fd0e5438e023d9c8cc8b7d35ada1e49 Zhihong Yu committed Feb 24, 2012
Showing with 26 additions and 18 deletions.
  1. +2 −0 CHANGES.txt
  2. +24 −18 src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java
View
2 CHANGES.txt
@@ -12,6 +12,8 @@ Release 0.92.1 - Unreleased
HBASE-5243 LogSyncerThread not getting shutdown waiting for the interrupted flag (Ram)
HBASE-5255 Use singletons for OperationStatus to save memory (Benoit)
HBASE-5345 CheckAndPut doesn't work when value is empty byte[] (Evert Arckens)
+ HBASE-5466 Opening a table also opens the metatable and never closes it
+ (Ashley Taylor)
TESTS
HBASE-5223 TestMetaReaderEditor is missing call to CatalogTracker.stop()
View
42 src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java
@@ -145,25 +145,31 @@ private static void metaScan(Configuration configuration, HConnection connection
byte[] searchRow =
HRegionInfo.createRegionName(tableName, row, HConstants.NINES,
false);
-
- HTable metaTable = new HTable(configuration, HConstants.META_TABLE_NAME);
- Result startRowResult = metaTable.getRowOrBefore(searchRow,
- HConstants.CATALOG_FAMILY);
- if (startRowResult == null) {
- throw new TableNotFoundException("Cannot find row in .META. for table: "
- + Bytes.toString(tableName) + ", row=" + Bytes.toStringBinary(searchRow));
- }
- byte[] value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
- HConstants.REGIONINFO_QUALIFIER);
- if (value == null || value.length == 0) {
- throw new IOException("HRegionInfo was null or empty in Meta for " +
- Bytes.toString(tableName) + ", row=" + Bytes.toStringBinary(searchRow));
+ HTable metaTable = null;
+ try {
+ metaTable = new HTable(configuration, HConstants.META_TABLE_NAME);
+ Result startRowResult = metaTable.getRowOrBefore(searchRow,
+ HConstants.CATALOG_FAMILY);
+ if (startRowResult == null) {
+ throw new TableNotFoundException("Cannot find row in .META. for table: "
+ + Bytes.toString(tableName) + ", row=" + Bytes.toStringBinary(searchRow));
+ }
+ byte[] value = startRowResult.getValue(HConstants.CATALOG_FAMILY,
+ HConstants.REGIONINFO_QUALIFIER);
+ if (value == null || value.length == 0) {
+ throw new IOException("HRegionInfo was null or empty in Meta for " +
+ Bytes.toString(tableName) + ", row=" + Bytes.toStringBinary(searchRow));
+ }
+ HRegionInfo regionInfo = Writables.getHRegionInfo(value);
+
+ byte[] rowBefore = regionInfo.getStartKey();
+ startRow = HRegionInfo.createRegionName(tableName, rowBefore,
+ HConstants.ZEROES, false);
+ } finally {
+ if (metaTable != null) {
+ metaTable.close();
+ }
}
- HRegionInfo regionInfo = Writables.getHRegionInfo(value);
-
- byte[] rowBefore = regionInfo.getStartKey();
- startRow = HRegionInfo.createRegionName(tableName, rowBefore,
- HConstants.ZEROES, false);
} else if (tableName == null || tableName.length == 0) {
// Full META scan
startRow = HConstants.EMPTY_START_ROW;

0 comments on commit 75d4931

Please sign in to comment.