[
https://issues.apache.org/jira/browse/CALCITE-1052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15097157#comment-15097157
]
Josh Elser commented on CALCITE-1052:
-------------------------------------
bq. What adaptations did you make
I used the table definitions I provided earlier instead of what your client
code was doing (since you didn't provide the commands to create and populate
for your tables).
bq. It may be a server configuration issue but the Docker image replicates our
environment.
I don't have the facilities to run your Docker container set up. That's why I
had to try to reproduce what you told me you did :). I plan to try to do this,
but it'd be much easier for me to not pull Docker into the equation.
bq. I haven't had success manually compiling and upgrading Phoenix before. I
get errors when I try to connect to the queryserver after replacing the jars.
What were the steps you took to build Phoenix? This shouldn't be difficult.
1. `mvn clean && mvn install -DskipTests` on calcite
2. `mvn clean package -DskipTests -Dcalcite.version=1.6.0-SNAPSHOT` on Phoenix
3. `cd phoenix-assembly/target && tar xf
phoenix-4.7.0-HBase-1.1-SNAPSHOT.tar.gz`
4. Copy {{phoenix-4.7.0-HBase-1.1-SNAPSHOT/*.jar}},
{{phoenix-4.7.0-HBase-1.1-SNAPSHOT/lib/calcite*.jar}},
{{phoenix-4.7.0-HBase-1.1-SNAPSHOT/lib/phoenix-server*.jar}} to your Phoenix
install
> Phoenix queryserver sends result set in response to the wrong request when
> there are concurrent requests
> --------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-1052
> URL: https://issues.apache.org/jira/browse/CALCITE-1052
> Project: Calcite
> Issue Type: Bug
> Components: avatica
> Reporter: Kevin Liew
> Assignee: Josh Elser
> Priority: Critical
> Labels: phoenix, queryserver
> Attachments: test.zip
>
>
> Create two tables
> {code:sql}
> DROP TABLE IF EXISTS SEN.VARCHAR_TABLE;
> CREATE TABLE IF NOT EXISTS SEN.VARCHAR_TABLE(
> KeyColumn VARCHAR(255) PRIMARY KEY,
> Column1 VARCHAR(510));
> UPSERT INTO SEN.VARCHAR_TABLE VALUES ("One","1");
> {code}
> {code:sql}
> DROP TABLE IF EXISTS SEN.INTEGER_TABLE;
> CREATE TABLE IF NOT EXISTS SEN.INTEGER_TABLE(
> KeyColumn VARCHAR(255) PRIMARY KEY,
> Column1 INTEGER);
> UPSERT INTO SEN.VARCHAR_TABLE VALUES ("Two",2);
> {code}
> Running these two programs results in several crashes.
> 1. select a varchar by parameterized statement resulting in
> SELECT Column1 FROM SEN.VARCHAR_TABLE WHERE KeyColumn = 'One'
> {code:java}
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.ResultSet;
> import java.sql.SQLException;
> import java.sql.PreparedStatement;
> import java.sql.Statement;
> public class Hello_World {
> public static void main(String[] args) throws SQLException {
> try {
> Class.forName("org.apache.phoenix.queryserver.client.Driver");
> } catch (ClassNotFoundException e) {
> System.out.println("Where is your PhoenixDriver");
> e.printStackTrace();
> return;
> }
> Connection conn =
> DriverManager.getConnection("jdbc:phoenix:thin:url=http://192.168.222.52:8765");
> conn.setAutoCommit(true);
> String sqlStmt = "SELECT Column1 FROM SEN.VARCHAR_TABLE WHERE
> KeyColumn = ?";
> System.out.println("SQL Statement:\n\t" + sqlStmt);
>
> while(true)
> {
> ResultSet rset = null;
>
> //Statement stmt = conn.createStatement();
> PreparedStatement stmt = conn.prepareStatement(sqlStmt);
> stmt.setString(1, "One");
> ResultSet rs = stmt.executeQuery();
>
> while (rs.next()) {
> String column1 = rs.getString("column1");
> if (!column1.equals("1"))
> {
> System.out.println(column1);
> }
> }
> }
>
> //conn.close();
> }
>
> }
> {code}
> 2. select an integer by parameterized statement resulting in
> SELECT Column1 FROM SEN.INTEGER_TABLE WHERE KeyColumn = 'Two'
> {code:java}
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.ResultSet;
> import java.sql.SQLException;
> import java.sql.PreparedStatement;
> import java.sql.Statement;
> public class Hello_World {
> public static void main(String[] args) throws SQLException {
> try {
> Class.forName("org.apache.phoenix.queryserver.client.Driver");
> } catch (ClassNotFoundException e) {
> System.out.println("Where is your PhoenixDriver");
> e.printStackTrace();
> return;
> }
> Connection conn =
> DriverManager.getConnection("jdbc:phoenix:thin:url=http://192.168.222.52:8765");
> conn.setAutoCommit(true);
>
> String sqlStmt = "SELECT Column1 FROM SEN.INTEGER_TABLE WHERE
> KeyColumn = ?";
> System.out.println("SQL Statement:\n\t" + sqlStmt);
>
> while(true)
> {
> ResultSet rset = null;
>
> //Statement stmt = conn.createStatement();
> PreparedStatement stmt = conn.prepareStatement(sqlStmt);
> stmt.setString(1, "Two");
> ResultSet rs = stmt.executeQuery();
>
> while (rs.next()) {
> int column1 = rs.getInt("column1");
> if (column1 != 2)
> {
> System.out.println(column1);
> }
> }
> }
>
> //conn.close();
> }
>
> }
> {code}
> There are several crashes (might be preventable by adding a pause in the
> loops?), but the one relevant to this bug is:
> {code:java}
> SQL Statement:
> SELECT Column1 FROM SEN.INTEGER_TABLE WHERE KeyColumn = ?
> Exception in thread "main" java.lang.ClassCastException: java.lang.String
> cannot be cast to java.lang.Number
> at
> org.apache.calcite.avatica.util.AbstractCursor$NumberAccessor.getNumber(AbstractCursor.java:661)
> at
> org.apache.calcite.avatica.util.AbstractCursor$BigNumberAccessor.getInt(AbstractCursor.java:602)
> at
> org.apache.calcite.avatica.AvaticaResultSet.getInt(AvaticaResultSet.java:314)
> at Hello_World.main(Hello_World.java:36)
> {code}
> where we get a string from SEN.VARCHAR_TABLE while we are querying from the
> SEN.INTEGER_TABLE.
> The queryserver is sending the result set in response to a request made from
> another connection id. The statement id was not checked but there may have
> been a statement id collision
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)