phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sama...@apache.org
Subject phoenix git commit: PHOENIX-2447 Phoenix throwing exception when requesting data from hbase when the table is being split (Alicia Ying Shu)
Date Thu, 10 Dec 2015 22:45:45 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.0 f995761e6 -> 9eb25340c


PHOENIX-2447 Phoenix throwing exception when requesting data from hbase when the table is
being split (Alicia Ying Shu)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/9eb25340
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/9eb25340
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/9eb25340

Branch: refs/heads/4.x-HBase-1.0
Commit: 9eb25340c343b299bb4c957f21aef0fd6de66703
Parents: f995761
Author: Samarth <samarth@apache.org>
Authored: Thu Dec 10 14:45:34 2015 -0800
Committer: Samarth <samarth@apache.org>
Committed: Thu Dec 10 14:45:34 2015 -0800

----------------------------------------------------------------------
 .../phoenix/iterate/BaseResultIterators.java    | 37 ++++++++------------
 1 file changed, 15 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9eb25340/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
index c18233e..6ad57c3 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
@@ -531,24 +531,32 @@ public abstract class BaseResultIterators extends ExplainTable implements
Result
             logger.debug(LogUtil.addCustomAnnotations("Getting iterators for " + this,
                     ScanUtil.getCustomAnnotations(scan)));
         }
-        boolean success = false;
         boolean isReverse = ScanUtil.isReversed(scan);
         boolean isLocalIndex = getTable().getIndexType() == IndexType.LOCAL;
         final ConnectionQueryServices services = context.getConnection().getQueryServices();
+        // Get query time out from Statement
+        final long startTime = System.currentTimeMillis();
+        final long maxQueryEndTime = startTime + context.getStatement().getQueryTimeoutInMillis();
         int numScans = size();
         // Capture all iterators so that if something goes wrong, we close them all
         // The iterators list is based on the submission of work, so it may not
         // contain them all (for example if work was rejected from the queue)
         Queue<PeekingResultIterator> allIterators = new ConcurrentLinkedQueue<>();
         List<PeekingResultIterator> iterators = new ArrayList<PeekingResultIterator>(numScans);
-        final List<List<Pair<Scan,Future<PeekingResultIterator>>>>
futures = Lists.newArrayListWithExpectedSize(numScans);
+        return getIterators(scans, services, isLocalIndex, allIterators, iterators, isReverse,
maxQueryEndTime,
+                splits.size());
+    }
+
+    private List<PeekingResultIterator> getIterators(List<List<Scan>> scan,
ConnectionQueryServices services, boolean isLocalIndex,
+        Queue<PeekingResultIterator> allIterators, List<PeekingResultIterator>
iterators, boolean isReverse, long maxQueryEndTime, int splitSize)
+                throws SQLException {
+        boolean success = false;
+        final List<List<Pair<Scan,Future<PeekingResultIterator>>>>
futures = Lists.newArrayListWithExpectedSize(splitSize);
         allFutures.add(futures);
         SQLException toThrow = null;
         int queryTimeOut = context.getStatement().getQueryTimeoutInMillis();
-        final long startTime = System.currentTimeMillis();
-        final long maxQueryEndTime = startTime + queryTimeOut;
         try {
-            submitWork(scans, futures, allIterators, splits.size());
+            submitWork(scan, futures, allIterators, splitSize);
             boolean clearedCache = false;
             for (List<Pair<Scan,Future<PeekingResultIterator>>> future
: reverseIfNecessary(futures,isReverse)) {
                 List<PeekingResultIterator> concatIterators = Lists.newArrayListWithExpectedSize(future.size());
@@ -565,10 +573,8 @@ public abstract class BaseResultIterators extends ExplainTable implements
Result
                             throw ServerUtil.parseServerException(e);
                         } catch (StaleRegionBoundaryCacheException e2) {
                             // Catch only to try to recover from region boundary cache being
out of date
-                            List<List<Pair<Scan,Future<PeekingResultIterator>>>>
newFutures = Lists.newArrayListWithExpectedSize(2);
                             if (!clearedCache) { // Clear cache once so that we rejigger
job based on new boundaries
                                 services.clearTableRegionCache(physicalTableName);
-                                clearedCache = true;
                                 context.getOverallQueryMetrics().cacheRefreshedDueToSplits();
                             }
                             // Resubmit just this portion of work again
@@ -583,21 +589,8 @@ public abstract class BaseResultIterators extends ExplainTable implements
Result
                             // as we need these to be in order
                             addIterator(iterators, concatIterators);
                             concatIterators = Lists.newArrayList();
-                            submitWork(newNestedScans, newFutures, allIterators, newNestedScans.size());
-                            allFutures.add(newFutures);
-                            for (List<Pair<Scan,Future<PeekingResultIterator>>>
newFuture : reverseIfNecessary(newFutures, isReverse)) {
-                                for (Pair<Scan,Future<PeekingResultIterator>>
newScanPair : reverseIfNecessary(newFuture, isReverse)) {
-                                    // Immediate do a get (not catching exception again)
and then add the iterators we
-                                    // get back immediately. They'll be sorted as expected,
since they're replacing the
-                                    // original one.
-                                    long timeOutForScan = maxQueryEndTime - System.currentTimeMillis();
-                                    if (timeOutForScan < 0) {
-                                        throw new SQLExceptionInfo.Builder(SQLExceptionCode.OPERATION_TIMED_OUT).setMessage(".
Query couldn't be completed in the alloted time: " + queryTimeOut + " ms").build().buildException();

-                                    }
-                                    PeekingResultIterator iterator = newScanPair.getSecond().get(timeOutForScan,
TimeUnit.MILLISECONDS);
-                                    iterators.add(iterator);
-                                }
-                            }
+                            getIterators(newNestedScans, services, isLocalIndex, allIterators,
iterators, isReverse,
+                                    maxQueryEndTime, newNestedScans.size());
                         }
                     }
                 }


Mime
View raw message