You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2019/02/27 10:09:26 UTC
[hbase] branch branch-2.0 updated: HBASE-21961 Infinite loop in
AsyncNonMetaRegionLocator if there is only one region and we tried to
locate before a non empty row
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new eb2e6c0 HBASE-21961 Infinite loop in AsyncNonMetaRegionLocator if there is only one region and we tried to locate before a non empty row
eb2e6c0 is described below
commit eb2e6c01bece4bf70c01b9d498e01ddbabb688e2
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Wed Feb 27 17:54:30 2019 +0800
HBASE-21961 Infinite loop in AsyncNonMetaRegionLocator if there is only one region and we tried to locate before a non empty row
Signed-off-by: Guanghao Zhang <zg...@apache.org>
---
.../apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java | 8 +++++---
.../hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java | 11 +++++++++++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java
index 7f19709..a4843f8 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java
@@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hbase.client;
+import static org.apache.hadoop.hbase.HConstants.EMPTY_END_ROW;
import static org.apache.hadoop.hbase.HConstants.NINES;
import static org.apache.hadoop.hbase.HConstants.ZEROES;
import static org.apache.hadoop.hbase.TableName.META_TABLE_NAME;
@@ -169,9 +170,10 @@ class AsyncNonMetaRegionLocator {
// startKey < req.row and endKey >= req.row. Here we split it to endKey == req.row ||
// (endKey > req.row && startKey < req.row). The two conditions are equal since startKey <
// endKey.
- int c = Bytes.compareTo(loc.getRegion().getEndKey(), req.row);
- completed =
- c == 0 || (c > 0 && Bytes.compareTo(loc.getRegion().getStartKey(), req.row) < 0);
+ byte[] endKey = loc.getRegion().getEndKey();
+ int c = Bytes.compareTo(endKey, req.row);
+ completed = c == 0 || ((c > 0 || Bytes.equals(EMPTY_END_ROW, endKey)) &&
+ Bytes.compareTo(loc.getRegion().getStartKey(), req.row) < 0);
} else {
completed = loc.getRegion().containsRow(req.row);
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java
index eeaf99f..cb09b79 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncNonMetaRegionLocator.java
@@ -389,4 +389,15 @@ public class TestAsyncNonMetaRegionLocator {
}
});
}
+
+ // Testcase for HBASE-21961
+ @Test
+ public void testLocateBeforeInOnlyRegion() throws IOException, InterruptedException {
+ createSingleRegionTable();
+ HRegionLocation loc =
+ getDefaultRegionLocation(TABLE_NAME, Bytes.toBytes(1), RegionLocateType.BEFORE, false).join();
+ // should locate to the only region
+ assertArrayEquals(loc.getRegion().getStartKey(), EMPTY_START_ROW);
+ assertArrayEquals(loc.getRegion().getEndKey(), EMPTY_END_ROW);
+ }
}