Repository: phoenix Updated Branches: refs/heads/4.4-HBase-1.0 a7333c8a6 -> 8133f89d1
PHOENIX-2074 StackOverflowError for hash join with round robin Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/8133f89d Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/8133f89d Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/8133f89d Branch: refs/heads/4.4-HBase-1.0 Commit: 8133f89d16541fa61ec9d0b8c0ced72ad2ffe851 Parents: a7333c8 Author: maryannxue <wei....@intel.com> Authored: Tue Jul 7 14:10:45 2015 -0400 Committer: maryannxue <wei....@intel.com> Committed: Tue Jul 7 14:10:45 2015 -0400 ---------------------------------------------------------------------- .../iterate/RoundRobinResultIteratorIT.java | 80 ++++++++++++++++++++ .../iterate/RoundRobinResultIterator.java | 2 +- 2 files changed, 81 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/8133f89d/phoenix-core/src/it/java/org/apache/phoenix/iterate/RoundRobinResultIteratorIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/iterate/RoundRobinResultIteratorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/iterate/RoundRobinResultIteratorIT.java index 6a9b3d4..224ed95 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/iterate/RoundRobinResultIteratorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/iterate/RoundRobinResultIteratorIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.iterate; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; @@ -30,6 +31,7 @@ import java.sql.Statement; import java.util.Collections; import java.util.HashSet; import java.util.Map; +import java.util.Properties; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -43,6 +45,7 @@ import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixResultSet; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; import org.junit.Test; @@ -301,6 +304,83 @@ public class RoundRobinResultIteratorIT extends BaseHBaseManagedTimeIT { assertEquals("Number of rows retrieved didnt match for tableB", insertedRowsB, rowsB); assertEquals("Number of rows retrieved didn't match for tableC", insertedRowsC, rowsC); } + + @Test + public void testBug2074() throws Exception { + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + Connection conn = DriverManager.getConnection(getUrl(), props); + try { + conn.createStatement().execute("CREATE TABLE EVENTS" + + " (id VARCHAR(10) PRIMARY KEY, " + + " article VARCHAR(10), " + + " misc VARCHAR(10))"); + + PreparedStatement upsertStmt = conn.prepareStatement( + "upsert into EVENTS(id, article, misc) " + "values (?, ?, ?)"); + upsertStmt.setString(1, "001"); + upsertStmt.setString(2, "A"); + upsertStmt.setString(3, "W"); + upsertStmt.execute(); + upsertStmt.setString(1, "002"); + upsertStmt.setString(2, "B"); + upsertStmt.setString(3, "X"); + upsertStmt.execute(); + upsertStmt.setString(1, "003"); + upsertStmt.setString(2, "C"); + upsertStmt.setString(3, "Y"); + upsertStmt.execute(); + upsertStmt.setString(1, "004"); + upsertStmt.setString(2, "D"); + upsertStmt.setString(3, "Z"); + upsertStmt.execute(); + conn.commit(); + + conn.createStatement().execute("CREATE TABLE MAPPING" + + " (id VARCHAR(10) PRIMARY KEY, " + + " article VARCHAR(10), " + + " category VARCHAR(10))"); + + upsertStmt = conn.prepareStatement( + "upsert into MAPPING(id, article, category) " + "values (?, ?, ?)"); + upsertStmt.setString(1, "002"); + upsertStmt.setString(2, "A"); + upsertStmt.setString(3, "X"); + upsertStmt.execute(); + upsertStmt.setString(1, "003"); + upsertStmt.setString(2, "B"); + upsertStmt.setString(3, "Y"); + upsertStmt.execute(); + upsertStmt.setString(1, "004"); + upsertStmt.setString(2, "C"); + upsertStmt.setString(3, "Z"); + upsertStmt.execute(); + upsertStmt.setString(1, "005"); + upsertStmt.setString(2, "E"); + upsertStmt.setString(3, "Z"); + upsertStmt.execute(); + upsertStmt.setString(1, "006"); + upsertStmt.setString(2, "C"); + upsertStmt.setString(3, "Z"); + upsertStmt.execute(); + upsertStmt.setString(1, "007"); + upsertStmt.setString(2, "C"); + upsertStmt.setString(3, "Z"); + upsertStmt.execute(); + conn.commit(); + + // No leading part of PK + String query = "select count(MAPPING.article) as cnt,MAPPING.category from EVENTS" + + " join MAPPING on MAPPING.article = EVENTS.article" + + " group by category order by cnt"; + PreparedStatement statement = conn.prepareStatement(query); + statement.setFetchSize(3); + ResultSet rs = statement.executeQuery(); + while(rs.next()); + + } finally { + conn.close(); + } + } private static ResultIterator getResultIterator(ResultSet rs) throws SQLException { http://git-wip-us.apache.org/repos/asf/phoenix/blob/8133f89d/phoenix-core/src/main/java/org/apache/phoenix/iterate/RoundRobinResultIterator.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/RoundRobinResultIterator.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/RoundRobinResultIterator.java index 4a9ad3e..0ffed5a 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/RoundRobinResultIterator.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/RoundRobinResultIterator.java @@ -240,7 +240,7 @@ public class RoundRobinResultIterator implements ResultIterator { for (Future<Tuple> future : futures) { Tuple tuple = future.get(); if (tuple != null) { - results.add(new RoundRobinIterator(openIterators.get(i), tuple)); + results.add(new RoundRobinIterator(openIterators.get(i).delegate, tuple)); } else { // Underlying scanner is exhausted. So close it. openIterators.get(i).close();