You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ra...@apache.org on 2020/09/14 14:52:17 UTC
[phoenix] branch master updated: PHOENIX-6130
StatementContext.subqueryResults should be thread safe
This is an automated email from the ASF dual-hosted git repository.
rajeshbabu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push:
new 11cc4cd PHOENIX-6130 StatementContext.subqueryResults should be thread safe
new da573bb Merge pull request #879 from brfrn169/PHOENIX-6130
11cc4cd is described below
commit 11cc4cd0231d720dc2cd9ea4b214f79e069eb2fd
Author: Toshihiro Suzuki <br...@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 a4f7198..7d49085 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
@@ -140,7 +140,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();