Repository: phoenix Updated Branches: refs/heads/4.x-cdh5.11.2 cc23187fb -> 6caf7e960
PHOENIX-4576 Correct local index wrongly using child region scanners Was causing failures in LocalIndexSplitMergeIT. Signed-off-by: Josh Elser <els...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/4debdd1d Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/4debdd1d Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/4debdd1d Branch: refs/heads/4.x-cdh5.11.2 Commit: 4debdd1d9a0c86fccce919537b2c83e23f4c6550 Parents: cc23187 Author: Rajeshbabu Chintaguntla <rajeshb...@apache.org> Authored: Mon Mar 19 16:32:08 2018 +0000 Committer: Pedro Boado <pbo...@apache.org> Committed: Wed Mar 21 20:17:30 2018 +0000 ---------------------------------------------------------------------- .../regionserver/IndexHalfStoreFileReaderGenerator.java | 10 ++++++++++ .../phoenix/coprocessor/BaseScannerRegionObserver.java | 2 +- .../src/main/java/org/apache/phoenix/util/ScanUtil.java | 12 +++++------- 3 files changed, 16 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/4debdd1d/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java index 140b0ba..12fa47a 100644 --- a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java +++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java @@ -361,6 +361,16 @@ public class IndexHalfStoreFileReaderGenerator extends BaseRegionObserver { ()); final List<KeyValueScanner> keyValueScanners = new ArrayList<>(store .getStorefiles().size() + 1); + byte[] startKey = c.getEnvironment().getRegionInfo().getStartKey(); + byte[] endKey = c.getEnvironment().getRegionInfo().getEndKey(); + // If the region start key is not the prefix of the scan start row then we can return empty + // scanners. This is possible during merge where one of the child region scan should not return any + // results as we go through merged region. + if (Bytes.compareTo(scan.getStartRow(), 0, startKey.length == 0 ? endKey.length + : startKey.length, startKey.length == 0 ? new byte[endKey.length] : startKey, 0, + startKey.length == 0 ? endKey.length : startKey.length) != 0) { + return keyValueScanners; + } for (StoreFile storeFile : storeFiles) { if (storeFile.isReference()) { referenceStoreFiles.add(storeFile); http://git-wip-us.apache.org/repos/asf/phoenix/blob/4debdd1d/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java index 9f55ca5..7ef64b0 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java @@ -179,7 +179,7 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { throw new DoNotRetryIOException(cause.getMessage(), cause); } if(isLocalIndex) { - ScanUtil.setupLocalIndexScan(scan, lowerInclusiveRegionKey, upperExclusiveRegionKey); + ScanUtil.setupLocalIndexScan(scan); } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/4debdd1d/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java index a844226..9c710c1 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java @@ -652,15 +652,13 @@ public class ScanUtil { } /** - * prefix region start key to the start row/stop row suffix and set as scan boundaries. + * Start key and stop key of the original scan from client are regions start and end keys so + * prefix scan start/stop key to the start row/stop row suffix and set them as scan boundaries. * @param scan - * @param lowerInclusiveRegionKey - * @param upperExclusiveRegionKey */ - public static void setupLocalIndexScan(Scan scan, byte[] lowerInclusiveRegionKey, - byte[] upperExclusiveRegionKey) { - byte[] prefix = lowerInclusiveRegionKey.length == 0 ? new byte[upperExclusiveRegionKey.length]: lowerInclusiveRegionKey; - int prefixLength = lowerInclusiveRegionKey.length == 0? upperExclusiveRegionKey.length: lowerInclusiveRegionKey.length; + public static void setupLocalIndexScan(Scan scan) { + byte[] prefix = scan.getStartRow().length == 0 ? new byte[scan.getStopRow().length]: scan.getStartRow(); + int prefixLength = scan.getStartRow().length == 0? scan.getStopRow().length: scan.getStartRow().length; if(scan.getAttribute(SCAN_START_ROW_SUFFIX)!=null) { scan.setStartRow(ScanRanges.prefixKey(scan.getAttribute(SCAN_START_ROW_SUFFIX), 0, prefix, prefixLength)); }