This is an automated email from the ASF dual-hosted git repository. rajeshbabu pushed a commit to branch 4.x in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x by this push: new 75973b6 PHOENIX-6130 StatementContext.subqueryResults should be thread safe 75973b6 is described below commit 75973b633db1c8ca62c518a3949ec842a9d98ad1 Author: Toshihiro Suzuki <brfrn...@gmail.com> AuthorDate: Sun Sep 13 22:31:33 2020 +0900 PHOENIX-6130 StatementContext.subqueryResults should be thread safe --- .../apache/phoenix/end2end/ToCharFunctionIT.java | 25 ++++++++++++++++++++++ .../apache/phoenix/compile/StatementContext.java | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToCharFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToCharFunctionIT.java index 022197c..6632886 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToCharFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToCharFunctionIT.java @@ -28,6 +28,7 @@ import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Statement; import java.sql.Time; import java.sql.Timestamp; import java.text.DateFormat; @@ -266,4 +267,28 @@ public class ToCharFunctionIT extends ParallelStatsDisabledIT { } conn.close(); } + + @Test + public void testToChar100Times() throws Exception { + String tableName = generateUniqueName(); + try (Connection conn = DriverManager.getConnection(getUrl()); + Statement statement = conn.createStatement()) { + conn.setAutoCommit(true); + statement.execute("create table " + tableName + + " (id varchar primary key, ts varchar)"); + statement.execute("upsert into " + tableName + + " values ('id', '1596067200000')"); + String query = "select ts from " + tableName + + " where ts <= (select to_char(" + + "cast(to_number(to_date('2020-07-30 00:00:00')) as BIGINT), '#############'))" + + " and ts >= (select to_char(" + + "cast(to_number(to_date('2020-07-29 00:00:00')) as BIGINT), '#############'))"; + for (int i = 0; i < 100; i++) { + try (ResultSet rs = statement.executeQuery(query)) { + // The query should always return a result + assertTrue(rs.next()); + } + } + } + } } \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java index b477049..ea0c58e 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java @@ -136,7 +136,7 @@ public class StatementContext { this.whereConditionColumns = new ArrayList<Pair<byte[], byte[]>>(); this.dataColumns = this.currentTable == null ? Collections.<PColumn, Integer> emptyMap() : Maps .<PColumn, Integer> newLinkedHashMap(); - this.subqueryResults = Maps.<SelectStatement, Object> newHashMap(); + this.subqueryResults = Maps.<SelectStatement, Object> newConcurrentMap(); this.readMetricsQueue = new ReadMetricQueue(isRequestMetricsEnabled,connection.getLogLevel()); this.overAllQueryMetrics = new OverAllQueryMetrics(isRequestMetricsEnabled,connection.getLogLevel()); this.retryingPersistentCache = Maps.<Long, Boolean> newHashMap();