[ 
https://issues.apache.org/jira/browse/CALCITE-1052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kevin Liew updated CALCITE-1052:
--------------------------------
    Attachment: phoenix-root-server.log

Attached server log file

{code:java}
2016-01-15 01:10:43,513 WARN org.eclipse.jetty.server.HttpChannel: /
java.lang.RuntimeException: java.sql.SQLException: ERROR 2004 (INT05): 
Parameter value unbound :1
        at org.apache.calcite.avatica.jdbc.JdbcMeta.propagate(JdbcMeta.java:689)
        at org.apache.calcite.avatica.jdbc.JdbcMeta.fetch(JdbcMeta.java:774)
        at 
org.apache.calcite.avatica.remote.LocalService.apply(LocalService.java:163)
        at 
org.apache.calcite.avatica.remote.Service$FetchRequest.accept(Service.java:330)
        at 
org.apache.calcite.avatica.remote.Service$FetchRequest.accept(Service.java:304)
        at 
org.apache.calcite.avatica.remote.JsonHandler.apply(JsonHandler.java:43)
        at 
org.apache.calcite.avatica.server.AvaticaHandler.handle(AvaticaHandler.java:55)
        at 
org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)
        at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
        at org.eclipse.jetty.server.Server.handle(Server.java:497)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
        at 
org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:245)
        at 
org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
        at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
        at 
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.sql.SQLException: ERROR 2004 (INT05): Parameter value unbound :1
        at 
org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:396)
        at 
org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:145)
        at 
org.apache.phoenix.compile.BindManager.getBindValue(BindManager.java:71)
        at 
org.apache.phoenix.compile.ExpressionCompiler.visit(ExpressionCompiler.java:427)
        at 
org.apache.phoenix.compile.ExpressionCompiler.visit(ExpressionCompiler.java:141)
        at org.apache.phoenix.parse.BindParseNode.accept(BindParseNode.java:47)
        at 
org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:64)
        at 
org.apache.phoenix.parse.ComparisonParseNode.accept(ComparisonParseNode.java:45)
        at 
org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:130)
        at 
org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:100)
        at 
org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:537)
        at 
org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:490)
        at 
org.apache.phoenix.compile.QueryCompiler.compileSelect(QueryCompiler.java:201)
        at 
org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:158)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:383)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:357)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:263)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:258)
        at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:257)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:245)
        at 
org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:172)
        at 
org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:177)
        at org.apache.calcite.avatica.jdbc.JdbcMeta.fetch(JdbcMeta.java:763)
        ... 14 more
{code}

> 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: phoenix-root-server.log, 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.INTEGER_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)

Reply via email to