[2/3] phoenix git commit: PHOENIX-2628 Ensure split when iterating through results handled correctly(Rajeshbabu)
http://git-wip-us.apache.org/repos/asf/phoenix/blob/119c5f90/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 96ee543..a391f05 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 @@ -29,6 +29,7 @@ import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue.Type; +import org.apache.hadoop.hbase.NotServingRegionException; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver; @@ -84,7 +85,6 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { public static final String LOCAL_INDEX_JOIN_SCHEMA = "_LocalIndexJoinSchema"; public static final String DATA_TABLE_COLUMNS_TO_JOIN = "_DataTableColumnsToJoin"; public static final String VIEW_CONSTANTS = "_ViewConstants"; -public static final String STARTKEY_OFFSET = "_StartKeyOffset"; public static final String EXPECTED_UPPER_REGION_KEY = "_ExpectedUpperRegionKey"; public static final String REVERSE_SCAN = "_ReverseScan"; public static final String ANALYZE_TABLE = "_ANALYZETABLE"; @@ -99,6 +99,8 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { public static final String SCAN_ACTUAL_START_ROW = "_ScanActualStartRow"; public static final String IGNORE_NEWER_MUTATIONS = "_IGNORE_NEWER_MUTATIONS"; public final static String SCAN_OFFSET = "_RowOffset"; +public static final String SCAN_START_ROW_SUFFIX = "_ScanStartRowSuffix"; +public static final String SCAN_STOP_ROW_SUFFIX = "_ScanStopRowSuffix"; /** * Attribute name used to pass custom annotations in Scans and Mutations (later). Custom annotations @@ -134,7 +136,9 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { byte[] upperExclusiveRegionKey = region.getEndKey(); boolean isStaleRegionBoundaries; if (isLocalIndex) { -byte[] expectedUpperRegionKey = scan.getAttribute(EXPECTED_UPPER_REGION_KEY); +byte[] expectedUpperRegionKey = +scan.getAttribute(EXPECTED_UPPER_REGION_KEY) == null ? scan.getStopRow() : scan +.getAttribute(EXPECTED_UPPER_REGION_KEY); isStaleRegionBoundaries = expectedUpperRegionKey != null && Bytes.compareTo(upperExclusiveRegionKey, expectedUpperRegionKey) != 0; } else { @@ -146,6 +150,9 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { Exception cause = new StaleRegionBoundaryCacheException(region.getRegionInfo().getTable().getNameAsString()); throw new DoNotRetryIOException(cause.getMessage(), cause); } +if(isLocalIndex) { +ScanUtil.setupLocalIndexScan(scan, lowerInclusiveRegionKey, upperExclusiveRegionKey); +} } abstract protected boolean isRegionObserverFor(Scan scan); @@ -165,7 +172,10 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { scan.setTimeRange(timeRange.getMin(), Bytes.toLong(txnScn)); } if (isRegionObserverFor(scan)) { -if (! skipRegionBoundaryCheck(scan)) { +// For local indexes, we need to throw if out of region as we'll get inconsistent +// results otherwise while in other cases, it may just mean out client-side data +// on region boundaries is out of date and can safely be ignored. +if (!skipRegionBoundaryCheck(scan) || ScanUtil.isLocalIndex(scan)) { throwIfScanOutOfRegion(scan, c.getEnvironment().getRegion()); } // Muck with the start/stop row of the scan and set as reversed at the @@ -226,6 +236,13 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { } } } catch (Throwable t) { +// If the exception is NotServingRegionException then throw it as +// StaleRegionBoundaryCacheException to handle it by phoenix client other wise hbase +// client may recreate scans with wrong region boundaries. +if(t instanceof NotServingRegionException) { +Exception cause = new StaleRegionBoundaryCacheException(c.getEnvironment().getRegion().getRegionInfo().getTable().getNameAsString()); +throw new
[2/3] phoenix git commit: PHOENIX-2628 Ensure split when iterating through results handled correctly(Rajeshbabu)
http://git-wip-us.apache.org/repos/asf/phoenix/blob/c7150ff8/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 8848efc..4c6b960 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 @@ -29,6 +29,7 @@ import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue.Type; +import org.apache.hadoop.hbase.NotServingRegionException; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver; @@ -42,6 +43,7 @@ import org.apache.hadoop.hbase.regionserver.ScannerContext; import org.apache.hadoop.hbase.util.Bytes; import org.apache.htrace.Span; import org.apache.htrace.Trace; +import org.apache.phoenix.compile.ScanRanges; import org.apache.phoenix.execute.TupleProjector; import org.apache.phoenix.expression.Expression; import org.apache.phoenix.expression.KeyValueColumnExpression; @@ -85,7 +87,6 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { public static final String LOCAL_INDEX_JOIN_SCHEMA = "_LocalIndexJoinSchema"; public static final String DATA_TABLE_COLUMNS_TO_JOIN = "_DataTableColumnsToJoin"; public static final String VIEW_CONSTANTS = "_ViewConstants"; -public static final String STARTKEY_OFFSET = "_StartKeyOffset"; public static final String EXPECTED_UPPER_REGION_KEY = "_ExpectedUpperRegionKey"; public static final String REVERSE_SCAN = "_ReverseScan"; public static final String ANALYZE_TABLE = "_ANALYZETABLE"; @@ -100,6 +101,8 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { public static final String SCAN_ACTUAL_START_ROW = "_ScanActualStartRow"; public static final String IGNORE_NEWER_MUTATIONS = "_IGNORE_NEWER_MUTATIONS"; public final static String SCAN_OFFSET = "_RowOffset"; +public static final String SCAN_START_ROW_SUFFIX = "_ScanStartRowSuffix"; +public static final String SCAN_STOP_ROW_SUFFIX = "_ScanStopRowSuffix"; /** * Attribute name used to pass custom annotations in Scans and Mutations (later). Custom annotations @@ -135,7 +138,9 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { byte[] upperExclusiveRegionKey = region.getRegionInfo().getEndKey(); boolean isStaleRegionBoundaries; if (isLocalIndex) { -byte[] expectedUpperRegionKey = scan.getAttribute(EXPECTED_UPPER_REGION_KEY); +byte[] expectedUpperRegionKey = +scan.getAttribute(EXPECTED_UPPER_REGION_KEY) == null ? scan.getStopRow() : scan +.getAttribute(EXPECTED_UPPER_REGION_KEY); isStaleRegionBoundaries = expectedUpperRegionKey != null && Bytes.compareTo(upperExclusiveRegionKey, expectedUpperRegionKey) != 0; } else { @@ -147,6 +152,9 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { Exception cause = new StaleRegionBoundaryCacheException(region.getRegionInfo().getTable().getNameAsString()); throw new DoNotRetryIOException(cause.getMessage(), cause); } +if(isLocalIndex) { +ScanUtil.setupLocalIndexScan(scan, lowerInclusiveRegionKey, upperExclusiveRegionKey); +} } abstract protected boolean isRegionObserverFor(Scan scan); @@ -166,7 +174,10 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { scan.setTimeRange(timeRange.getMin(), Bytes.toLong(txnScn)); } if (isRegionObserverFor(scan)) { -if (! skipRegionBoundaryCheck(scan)) { +// For local indexes, we need to throw if out of region as we'll get inconsistent +// results otherwise while in other cases, it may just mean out client-side data +// on region boundaries is out of date and can safely be ignored. +if (!skipRegionBoundaryCheck(scan) || ScanUtil.isLocalIndex(scan)) { throwIfScanOutOfRegion(scan, c.getEnvironment().getRegion()); } // Muck with the start/stop row of the scan and set as reversed at the @@ -227,6 +238,13 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { } } } catch (Throwable t) { +// If the exception is NotServingRegionException then throw it as +//
[2/3] phoenix git commit: PHOENIX-2628 Ensure split when iterating through results handled correctly(Rajeshbabu)
http://git-wip-us.apache.org/repos/asf/phoenix/blob/d700c1f0/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 8848efc..4c6b960 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 @@ -29,6 +29,7 @@ import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue.Type; +import org.apache.hadoop.hbase.NotServingRegionException; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver; @@ -42,6 +43,7 @@ import org.apache.hadoop.hbase.regionserver.ScannerContext; import org.apache.hadoop.hbase.util.Bytes; import org.apache.htrace.Span; import org.apache.htrace.Trace; +import org.apache.phoenix.compile.ScanRanges; import org.apache.phoenix.execute.TupleProjector; import org.apache.phoenix.expression.Expression; import org.apache.phoenix.expression.KeyValueColumnExpression; @@ -85,7 +87,6 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { public static final String LOCAL_INDEX_JOIN_SCHEMA = "_LocalIndexJoinSchema"; public static final String DATA_TABLE_COLUMNS_TO_JOIN = "_DataTableColumnsToJoin"; public static final String VIEW_CONSTANTS = "_ViewConstants"; -public static final String STARTKEY_OFFSET = "_StartKeyOffset"; public static final String EXPECTED_UPPER_REGION_KEY = "_ExpectedUpperRegionKey"; public static final String REVERSE_SCAN = "_ReverseScan"; public static final String ANALYZE_TABLE = "_ANALYZETABLE"; @@ -100,6 +101,8 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { public static final String SCAN_ACTUAL_START_ROW = "_ScanActualStartRow"; public static final String IGNORE_NEWER_MUTATIONS = "_IGNORE_NEWER_MUTATIONS"; public final static String SCAN_OFFSET = "_RowOffset"; +public static final String SCAN_START_ROW_SUFFIX = "_ScanStartRowSuffix"; +public static final String SCAN_STOP_ROW_SUFFIX = "_ScanStopRowSuffix"; /** * Attribute name used to pass custom annotations in Scans and Mutations (later). Custom annotations @@ -135,7 +138,9 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { byte[] upperExclusiveRegionKey = region.getRegionInfo().getEndKey(); boolean isStaleRegionBoundaries; if (isLocalIndex) { -byte[] expectedUpperRegionKey = scan.getAttribute(EXPECTED_UPPER_REGION_KEY); +byte[] expectedUpperRegionKey = +scan.getAttribute(EXPECTED_UPPER_REGION_KEY) == null ? scan.getStopRow() : scan +.getAttribute(EXPECTED_UPPER_REGION_KEY); isStaleRegionBoundaries = expectedUpperRegionKey != null && Bytes.compareTo(upperExclusiveRegionKey, expectedUpperRegionKey) != 0; } else { @@ -147,6 +152,9 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { Exception cause = new StaleRegionBoundaryCacheException(region.getRegionInfo().getTable().getNameAsString()); throw new DoNotRetryIOException(cause.getMessage(), cause); } +if(isLocalIndex) { +ScanUtil.setupLocalIndexScan(scan, lowerInclusiveRegionKey, upperExclusiveRegionKey); +} } abstract protected boolean isRegionObserverFor(Scan scan); @@ -166,7 +174,10 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { scan.setTimeRange(timeRange.getMin(), Bytes.toLong(txnScn)); } if (isRegionObserverFor(scan)) { -if (! skipRegionBoundaryCheck(scan)) { +// For local indexes, we need to throw if out of region as we'll get inconsistent +// results otherwise while in other cases, it may just mean out client-side data +// on region boundaries is out of date and can safely be ignored. +if (!skipRegionBoundaryCheck(scan) || ScanUtil.isLocalIndex(scan)) { throwIfScanOutOfRegion(scan, c.getEnvironment().getRegion()); } // Muck with the start/stop row of the scan and set as reversed at the @@ -227,6 +238,13 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver { } } } catch (Throwable t) { +// If the exception is NotServingRegionException then throw it as +//