PHOENIX-2560 PhoenixMetricsIT test failures
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/423bd134 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/423bd134 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/423bd134 Branch: refs/heads/4.x-HBase-1.0 Commit: 423bd134f6a9a25a2eaaa9d5d82b4be96cd6eba4 Parents: 1cd1d26 Author: James Taylor <jtay...@salesforce.com> Authored: Mon Jan 4 08:00:47 2016 -0800 Committer: James Taylor <jtay...@salesforce.com> Committed: Mon Jan 4 09:36:46 2016 -0800 ---------------------------------------------------------------------- .../MutatingParallelIteratorFactory.java | 18 +------------- .../phoenix/iterate/BaseResultIterators.java | 3 +++ .../iterate/MergeSortResultIterator.java | 25 +------------------- .../query/ConnectionQueryServicesImpl.java | 4 +++- 4 files changed, 8 insertions(+), 42 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/423bd134/phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java index 630760c..ed421a7 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/MutatingParallelIteratorFactory.java @@ -32,9 +32,6 @@ import org.apache.phoenix.iterate.ParallelIteratorFactory; import org.apache.phoenix.iterate.PeekingResultIterator; import org.apache.phoenix.iterate.ResultIterator; import org.apache.phoenix.jdbc.PhoenixConnection; -import org.apache.phoenix.query.ConnectionQueryServices; -import org.apache.phoenix.query.QueryServices; -import org.apache.phoenix.query.QueryServicesOptions; import org.apache.phoenix.schema.tuple.SingleKeyValueTuple; import org.apache.phoenix.schema.tuple.Tuple; import org.apache.phoenix.schema.types.PLong; @@ -64,20 +61,7 @@ public abstract class MutatingParallelIteratorFactory implements ParallelIterato long totalRowCount = state.getUpdateCount(); if (clonedConnection.getAutoCommit()) { clonedConnection.getMutationState().join(state); - clonedConnection.commit(); - ConnectionQueryServices services = clonedConnection.getQueryServices(); - int maxSize = services.getProps().getInt(QueryServices.MAX_MUTATION_SIZE_ATTRIB, QueryServicesOptions.DEFAULT_MAX_MUTATION_SIZE); - /* - * Everything that was mutated as part of the clonedConnection has been committed. However, we want to - * report the mutation work done using this clonedConnection as part of the overall mutation work of the - * parent connection. So we need to set those metrics in the empty mutation state so that they could be - * combined with the parent connection's mutation metrics (as part of combining mutation state) in the - * close() method of the iterator being returned. Don't combine the read metrics in parent context yet - * though because they are possibly being concurrently modified by other threads at this stage. Instead we - * will get hold of the read metrics when all the mutating iterators are done. - */ - state = MutationState.emptyMutationState(maxSize, clonedConnection); - state.getMutationMetricQueue().combineMetricQueues(clonedConnection.getMutationState().getMutationMetricQueue()); + state = clonedConnection.getMutationState(); } final MutationState finalState = state; http://git-wip-us.apache.org/repos/asf/phoenix/blob/423bd134/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 2806acd..715e7c4 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 @@ -700,6 +700,9 @@ public abstract class BaseResultIterators extends ExplainTable implements Result @Override public void close() throws SQLException { + if (allFutures.isEmpty()) { + return; + } // Don't call cancel on already started work, as it causes the HConnection // to get into a funk. Instead, just cancel queued work. boolean cancelledWork = false; http://git-wip-us.apache.org/repos/asf/phoenix/blob/423bd134/phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortResultIterator.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortResultIterator.java index e076a40..961e766 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortResultIterator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/MergeSortResultIterator.java @@ -24,8 +24,6 @@ import java.util.PriorityQueue; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.phoenix.schema.tuple.Tuple; -import org.apache.phoenix.util.SQLCloseables; -import org.apache.phoenix.util.ServerUtil; /** * Base class for a ResultIterator that does a merge sort on the list of iterators provided. @@ -43,28 +41,7 @@ public abstract class MergeSortResultIterator implements PeekingResultIterator { @Override public void close() throws SQLException { - SQLException toThrow = null; - try { - if (resultIterators != null) { - resultIterators.close(); - } - } catch (Exception e) { - toThrow = ServerUtil.parseServerException(e); - } finally { - try { - if (minHeap != null) { - SQLCloseables.closeAllQuietly(minHeap); - } - } catch (Exception e) { - if (toThrow == null) { - toThrow = ServerUtil.parseServerException(e); - } else { - toThrow.setNextException(ServerUtil.parseServerException(e)); - } - } finally { - if (toThrow != null) { throw toThrow; } - } - } + resultIterators.close(); } abstract protected int compare(Tuple t1, Tuple t2); http://git-wip-us.apache.org/repos/asf/phoenix/blob/423bd134/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java index 29b9756..daa7809 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java @@ -2487,7 +2487,9 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement @Override public MutationState updateData(MutationPlan plan) throws SQLException { - return plan.execute(); + MutationState state = plan.execute(); + plan.getContext().getConnection().commit(); + return state; } @Override