[
https://issues.apache.org/jira/browse/PHOENIX-2583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15092687#comment-15092687
]
Josh Elser commented on PHOENIX-2583:
-------------------------------------
bq. should this be moved to Calcite Avatica? Sounds pretty serious.
Yeah, nothing to change down here in Phoenix obviously.
{code}
try {
Class.forName("org.apache.phoenix.queryserver.client.Driver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your PhoenixDriver");
e.printStackTrace();
return;
}
{code}
Ugh, sorry you ran into that [~kliew]. I know what you're working around :)
One other question for you too, these are being invoked in separate JVMs (I'm
assuming since you have them in {{main(String[])}}'s). If these are in separate
JVMs, I'm very surprised by this (they should be completely isolated by the
connectionId). If you have them in the same JVM and are sharing the Driver
instance, you might just be running into the fact that the Avatica JDBC driver
isn't thread-safe (if I'm reading a recent calcite discussion).
Either way, moving this over to Calcite-landia to track it. Thanks for the
ping, James.
> Phoenix queryserver sends result set in response to the wrong request when
> there are concurrent requests
> --------------------------------------------------------------------------------------------------------
>
> Key: PHOENIX-2583
> URL: https://issues.apache.org/jira/browse/PHOENIX-2583
> Project: Phoenix
> Issue Type: Bug
> Reporter: Kevin Liew
> Priority: Critical
> Labels: phoenix, queryserver
>
> 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)