Failed to fetch SQL query result

classic Classic list List threaded Threaded
10 messages Options
yangjiajun yangjiajun
Reply | Threaded
Open this post in threaded view
|

Failed to fetch SQL query result

Hello.

I did a scan query on a table which has 8w records and tried to go through
all records in the result set but got following exception:

[13:53:31,523][SEVERE][client-connector-#77][JdbcRequestHandler] Failed to
fetch SQL query result [reqId=0, req=JdbcQueryFetchRequest
[queryId=38106237, pageSize=1024]]
class org.apache.ignite.internal.processors.query.IgniteSQLException: The
object is already closed [90007-195]
        at
org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.fetchNext(H2ResultSetIterator.java:136)
        at
org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.onHasNext(H2ResultSetIterator.java:142)
        at
org.apache.ignite.internal.util.GridCloseableIteratorAdapter.hasNextX(GridCloseableIteratorAdapter.java:53)
        at
org.apache.ignite.internal.util.lang.GridIteratorAdapter.hasNext(GridIteratorAdapter.java:45)
        at
org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator.hasNext(GridQueryCacheObjectsIterator.java:61)
        at
org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryCursor.fetchRows(JdbcQueryCursor.java:72)
        at
org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.fetchQuery(JdbcRequestHandler.java:587)
        at
org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.handle(JdbcRequestHandler.java:206)
        at
org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:160)
        at
org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:44)
        at
org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
        at
org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
        at
org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
        at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
        at
org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.h2.jdbc.JdbcSQLException: The object is already closed
[90007-195]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
        at org.h2.message.DbException.get(DbException.java:179)
        at org.h2.message.DbException.get(DbException.java:155)
        at org.h2.message.DbException.get(DbException.java:144)
        at org.h2.jdbc.JdbcResultSet.checkClosed(JdbcResultSet.java:3208)
        at org.h2.jdbc.JdbcResultSet.next(JdbcResultSet.java:130)
        at
org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.fetchNext(H2ResultSetIterator.java:110)
        ... 17 more

My ignite version is 2.6 and I only started one node.I did not call any
close methods. Why ignite closed my result set?

Here is my test code:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.Properties;

public class StatementTest {

        private static Connection conn;
       
       
        public static void main(String[] args) throws Exception {

                long t1 = System.currentTimeMillis();
                try {
                        initialize();
                       
                        String selectSql = "SELECT * FROM table_6932_r_1_1";
                        testQuery(selectSql);
                } catch (Exception e) {
                        throw e;
                } finally {
                        if (conn != null)
                                conn.close();
                }
                long t2 = System.currentTimeMillis();
                System.out.println("operation costs " + (t2 - t1) + " ms");
        }

        public static void close() throws Exception {
                conn.close();
        }
       
        public static void initialize() throws Exception {
                Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
                String dbUrl =
"jdbc:ignite:thin://ip:port;lazy=true;skipReducerOnUpdate=true;replicatedOnly=true";
                conn = DriverManager.getConnection(dbUrl, props);
        }
       
        public static void testUpdate(String sql) throws Exception {
                try (Statement stmt = conn.createStatement()) {
                        stmt.setQueryTimeout(10);
                        stmt.executeUpdate(sql);
                }
        }
       
        public static void testQuery(String sql) throws Exception {
                long startTime=System.currentTimeMillis();
                try (Statement stmt = conn.createStatement()) {
                        //stmt.setQueryTimeout(10);
                        try (ResultSet rs = stmt.executeQuery(sql)) {
                               
                                ResultSetMetaData rsmd = rs.getMetaData();
                                int colCount = rsmd.getColumnCount();
                                int count = 1;
                                try{
                                        while (rs.next()) {
                                                //Thread.sleep(10);
                                               
                                                for (int i = 1; i <= colCount; i++) {
                                                        System.out.print(rsmd.getColumnName(i) + ":" + rs.getObject(i) + "
");
                                                }
                                                System.out.println(count);
                                                count++;
                                        }
                                }catch(Exception e){
                                        System.out.println(System.currentTimeMillis()-startTime));
                                        System.out.println(rs.isClosed());
                                        System.out.println(stmt.isClosed());
                                        System.out.println(conn.isClosed());
                                }
                               
                        }
                }
        }
}



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Failed to fetch SQL query result

Hello!

Does this happen every time? If so, which is the # of row on which it will happen?

Regards,
--
Ilya Kasnacheev


вт, 27 нояб. 2018 г. в 10:09, yangjiajun <[hidden email]>:
Hello.

I did a scan query on a table which has 8w records and tried to go through
all records in the result set but got following exception:

[13:53:31,523][SEVERE][client-connector-#77][JdbcRequestHandler] Failed to
fetch SQL query result [reqId=0, req=JdbcQueryFetchRequest
[queryId=38106237, pageSize=1024]]
class org.apache.ignite.internal.processors.query.IgniteSQLException: The
object is already closed [90007-195]
        at
org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.fetchNext(H2ResultSetIterator.java:136)
        at
org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.onHasNext(H2ResultSetIterator.java:142)
        at
org.apache.ignite.internal.util.GridCloseableIteratorAdapter.hasNextX(GridCloseableIteratorAdapter.java:53)
        at
org.apache.ignite.internal.util.lang.GridIteratorAdapter.hasNext(GridIteratorAdapter.java:45)
        at
org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator.hasNext(GridQueryCacheObjectsIterator.java:61)
        at
org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryCursor.fetchRows(JdbcQueryCursor.java:72)
        at
org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.fetchQuery(JdbcRequestHandler.java:587)
        at
org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.handle(JdbcRequestHandler.java:206)
        at
org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:160)
        at
org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:44)
        at
org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
        at
org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
        at
org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
        at
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
        at
org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.h2.jdbc.JdbcSQLException: The object is already closed
[90007-195]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
        at org.h2.message.DbException.get(DbException.java:179)
        at org.h2.message.DbException.get(DbException.java:155)
        at org.h2.message.DbException.get(DbException.java:144)
        at org.h2.jdbc.JdbcResultSet.checkClosed(JdbcResultSet.java:3208)
        at org.h2.jdbc.JdbcResultSet.next(JdbcResultSet.java:130)
        at
org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.fetchNext(H2ResultSetIterator.java:110)
        ... 17 more

My ignite version is 2.6 and I only started one node.I did not call any
close methods. Why ignite closed my result set?

Here is my test code:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.Properties;

public class StatementTest {

        private static Connection conn;


        public static void main(String[] args) throws Exception {

                long t1 = System.currentTimeMillis();
                try {
                        initialize();

                        String selectSql = "SELECT * FROM table_6932_r_1_1";
                        testQuery(selectSql);
                } catch (Exception e) {
                        throw e;
                } finally {
                        if (conn != null)
                                conn.close();
                }
                long t2 = System.currentTimeMillis();
                System.out.println("operation costs " + (t2 - t1) + " ms");
        }

        public static void close() throws Exception {
                conn.close();
        }

        public static void initialize() throws Exception {
                Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
                String dbUrl =
"jdbc:ignite:thin://ip:port;lazy=true;skipReducerOnUpdate=true;replicatedOnly=true";
                conn = DriverManager.getConnection(dbUrl, props);
        }

        public static void testUpdate(String sql) throws Exception {
                try (Statement stmt = conn.createStatement()) {
                        stmt.setQueryTimeout(10);
                        stmt.executeUpdate(sql);
                }
        }

        public static void testQuery(String sql) throws Exception {
                long startTime=System.currentTimeMillis();
                try (Statement stmt = conn.createStatement()) {
                        //stmt.setQueryTimeout(10);
                        try (ResultSet rs = stmt.executeQuery(sql)) {

                                ResultSetMetaData rsmd = rs.getMetaData();
                                int colCount = rsmd.getColumnCount();
                                int count = 1;
                                try{
                                        while (rs.next()) {
                                                //Thread.sleep(10);

                                                for (int i = 1; i <= colCount; i++) {
                                                        System.out.print(rsmd.getColumnName(i) + ":" + rs.getObject(i) + "
");
                                                }
                                                System.out.println(count);
                                                count++;
                                        }
                                }catch(Exception e){
                                        System.out.println(System.currentTimeMillis()-startTime));
                                        System.out.println(rs.isClosed());
                                        System.out.println(stmt.isClosed());
                                        System.out.println(conn.isClosed());
                                }

                        }
                }
        }
}



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
yangjiajun yangjiajun
Reply | Threaded
Open this post in threaded view
|

Re: Failed to fetch SQL query result

Hello.

The error does not happen every time because it disappears when we restart
our application.But it repeats when first error appears.The row number is
not fixed when this error happens.We are really confused about this
exception.


ilya.kasnacheev wrote

> Hello!
>
> Does this happen every time? If so, which is the # of row on which it will
> happen?
>
> Regards,
> --
> Ilya Kasnacheev
>
>
> вт, 27 нояб. 2018 г. в 10:09, yangjiajun <

> 1371549332@

>>:
>
>> Hello.
>>
>> I did a scan query on a table which has 8w records and tried to go
>> through
>> all records in the result set but got following exception:
>>
>> [13:53:31,523][SEVERE][client-connector-#77][JdbcRequestHandler] Failed
>> to
>> fetch SQL query result [reqId=0, req=JdbcQueryFetchRequest
>> [queryId=38106237, pageSize=1024]]
>> class org.apache.ignite.internal.processors.query.IgniteSQLException: The
>> object is already closed [90007-195]
>>         at
>>
>> org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.fetchNext(H2ResultSetIterator.java:136)
>>         at
>>
>> org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.onHasNext(H2ResultSetIterator.java:142)
>>         at
>>
>> org.apache.ignite.internal.util.GridCloseableIteratorAdapter.hasNextX(GridCloseableIteratorAdapter.java:53)
>>         at
>>
>> org.apache.ignite.internal.util.lang.GridIteratorAdapter.hasNext(GridIteratorAdapter.java:45)
>>         at
>>
>> org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator.hasNext(GridQueryCacheObjectsIterator.java:61)
>>         at
>>
>> org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryCursor.fetchRows(JdbcQueryCursor.java:72)
>>         at
>>
>> org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.fetchQuery(JdbcRequestHandler.java:587)
>>         at
>>
>> org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.handle(JdbcRequestHandler.java:206)
>>         at
>>
>> org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:160)
>>         at
>>
>> org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:44)
>>         at
>>
>> org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
>>         at
>>
>> org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
>>         at
>>
>> org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
>>         at
>> org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
>>         at
>>
>> org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
>>         at
>>
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>>         at
>>
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>>         at java.lang.Thread.run(Thread.java:748)
>> Caused by: org.h2.jdbc.JdbcSQLException: The object is already closed
>> [90007-195]
>>         at
>> org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
>>         at org.h2.message.DbException.get(DbException.java:179)
>>         at org.h2.message.DbException.get(DbException.java:155)
>>         at org.h2.message.DbException.get(DbException.java:144)
>>         at org.h2.jdbc.JdbcResultSet.checkClosed(JdbcResultSet.java:3208)
>>         at org.h2.jdbc.JdbcResultSet.next(JdbcResultSet.java:130)
>>         at
>>
>> org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.fetchNext(H2ResultSetIterator.java:110)
>>         ... 17 more
>>
>> My ignite version is 2.6 and I only started one node.I did not call any
>> close methods. Why ignite closed my result set?
>>
>> Here is my test code:
>>
>> import java.sql.Connection;
>> import java.sql.DriverManager;
>> import java.sql.ResultSet;
>> import java.sql.ResultSetMetaData;
>> import java.sql.Statement;
>> import java.util.Properties;
>>
>> public class StatementTest {
>>
>>         private static Connection conn;
>>
>>
>>         public static void main(String[] args) throws Exception {
>>
>>                 long t1 = System.currentTimeMillis();
>>                 try {
>>                         initialize();
>>
>>                         String selectSql = "SELECT * FROM
>> table_6932_r_1_1";
>>                         testQuery(selectSql);
>>                 } catch (Exception e) {
>>                         throw e;
>>                 } finally {
>>                         if (conn != null)
>>                                 conn.close();
>>                 }
>>                 long t2 = System.currentTimeMillis();
>>                 System.out.println("operation costs " + (t2 - t1) + "
>> ms");
>>         }
>>
>>         public static void close() throws Exception {
>>                 conn.close();
>>         }
>>
>>         public static void initialize() throws Exception {
>>                 Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
>>                 String dbUrl =
>>
>> "jdbc:ignite:thin://ip:port;lazy=true;skipReducerOnUpdate=true;replicatedOnly=true";
>>                 conn = DriverManager.getConnection(dbUrl, props);
>>         }
>>
>>         public static void testUpdate(String sql) throws Exception {
>>                 try (Statement stmt = conn.createStatement()) {
>>                         stmt.setQueryTimeout(10);
>>                         stmt.executeUpdate(sql);
>>                 }
>>         }
>>
>>         public static void testQuery(String sql) throws Exception {
>>                 long startTime=System.currentTimeMillis();
>>                 try (Statement stmt = conn.createStatement()) {
>>                         //stmt.setQueryTimeout(10);
>>                         try (ResultSet rs = stmt.executeQuery(sql)) {
>>
>>                                 ResultSetMetaData rsmd =
>> rs.getMetaData();
>>                                 int colCount = rsmd.getColumnCount();
>>                                 int count = 1;
>>                                 try{
>>                                         while (rs.next()) {
>>                                                 //Thread.sleep(10);
>>
>>                                                 for (int i = 1; i <=
>> colCount; i++) {
>>
>> System.out.print(rsmd.getColumnName(i) + ":" + rs.getObject(i) + "
>> ");
>>                                                 }
>>                                                
>> System.out.println(count);
>>                                                 count++;
>>                                         }
>>                                 }catch(Exception e){
>>
>> System.out.println(System.currentTimeMillis()-startTime));
>>                                        
>> System.out.println(rs.isClosed());
>>
>> System.out.println(stmt.isClosed());
>>
>> System.out.println(conn.isClosed());
>>                                 }
>>
>>                         }
>>                 }
>>         }
>> }
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Failed to fetch SQL query result

Hello!

Can you provide logs from your nodes prior to seeing this exceptions?

Note that in a distributed system, you can expect to see this problem sometimes, i.e. to see a large lazy result set fail in mid-iteration due to some changes in the cluster. I'm not sure if there's nothimg more specific here, though.

Regards,
--
Ilya Kasnacheev


пн, 3 дек. 2018 г. в 06:21, yangjiajun <[hidden email]>:
Hello.

The error does not happen every time because it disappears when we restart
our application.But it repeats when first error appears.The row number is
not fixed when this error happens.We are really confused about this
exception.


ilya.kasnacheev wrote
> Hello!
>
> Does this happen every time? If so, which is the # of row on which it will
> happen?
>
> Regards,
> --
> Ilya Kasnacheev
>
>
> вт, 27 нояб. 2018 г. в 10:09, yangjiajun <

> 1371549332@

>>:
>
>> Hello.
>>
>> I did a scan query on a table which has 8w records and tried to go
>> through
>> all records in the result set but got following exception:
>>
>> [13:53:31,523][SEVERE][client-connector-#77][JdbcRequestHandler] Failed
>> to
>> fetch SQL query result [reqId=0, req=JdbcQueryFetchRequest
>> [queryId=38106237, pageSize=1024]]
>> class org.apache.ignite.internal.processors.query.IgniteSQLException: The
>> object is already closed [90007-195]
>>         at
>>
>> org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.fetchNext(H2ResultSetIterator.java:136)
>>         at
>>
>> org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.onHasNext(H2ResultSetIterator.java:142)
>>         at
>>
>> org.apache.ignite.internal.util.GridCloseableIteratorAdapter.hasNextX(GridCloseableIteratorAdapter.java:53)
>>         at
>>
>> org.apache.ignite.internal.util.lang.GridIteratorAdapter.hasNext(GridIteratorAdapter.java:45)
>>         at
>>
>> org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator.hasNext(GridQueryCacheObjectsIterator.java:61)
>>         at
>>
>> org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryCursor.fetchRows(JdbcQueryCursor.java:72)
>>         at
>>
>> org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.fetchQuery(JdbcRequestHandler.java:587)
>>         at
>>
>> org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.handle(JdbcRequestHandler.java:206)
>>         at
>>
>> org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:160)
>>         at
>>
>> org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:44)
>>         at
>>
>> org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
>>         at
>>
>> org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
>>         at
>>
>> org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
>>         at
>> org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
>>         at
>>
>> org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
>>         at
>>
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>>         at
>>
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>>         at java.lang.Thread.run(Thread.java:748)
>> Caused by: org.h2.jdbc.JdbcSQLException: The object is already closed
>> [90007-195]
>>         at
>> org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
>>         at org.h2.message.DbException.get(DbException.java:179)
>>         at org.h2.message.DbException.get(DbException.java:155)
>>         at org.h2.message.DbException.get(DbException.java:144)
>>         at org.h2.jdbc.JdbcResultSet.checkClosed(JdbcResultSet.java:3208)
>>         at org.h2.jdbc.JdbcResultSet.next(JdbcResultSet.java:130)
>>         at
>>
>> org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.fetchNext(H2ResultSetIterator.java:110)
>>         ... 17 more
>>
>> My ignite version is 2.6 and I only started one node.I did not call any
>> close methods. Why ignite closed my result set?
>>
>> Here is my test code:
>>
>> import java.sql.Connection;
>> import java.sql.DriverManager;
>> import java.sql.ResultSet;
>> import java.sql.ResultSetMetaData;
>> import java.sql.Statement;
>> import java.util.Properties;
>>
>> public class StatementTest {
>>
>>         private static Connection conn;
>>
>>
>>         public static void main(String[] args) throws Exception {
>>
>>                 long t1 = System.currentTimeMillis();
>>                 try {
>>                         initialize();
>>
>>                         String selectSql = "SELECT * FROM
>> table_6932_r_1_1";
>>                         testQuery(selectSql);
>>                 } catch (Exception e) {
>>                         throw e;
>>                 } finally {
>>                         if (conn != null)
>>                                 conn.close();
>>                 }
>>                 long t2 = System.currentTimeMillis();
>>                 System.out.println("operation costs " + (t2 - t1) + "
>> ms");
>>         }
>>
>>         public static void close() throws Exception {
>>                 conn.close();
>>         }
>>
>>         public static void initialize() throws Exception {
>>                 Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
>>                 String dbUrl =
>>
>> "jdbc:ignite:thin://ip:port;lazy=true;skipReducerOnUpdate=true;replicatedOnly=true";
>>                 conn = DriverManager.getConnection(dbUrl, props);
>>         }
>>
>>         public static void testUpdate(String sql) throws Exception {
>>                 try (Statement stmt = conn.createStatement()) {
>>                         stmt.setQueryTimeout(10);
>>                         stmt.executeUpdate(sql);
>>                 }
>>         }
>>
>>         public static void testQuery(String sql) throws Exception {
>>                 long startTime=System.currentTimeMillis();
>>                 try (Statement stmt = conn.createStatement()) {
>>                         //stmt.setQueryTimeout(10);
>>                         try (ResultSet rs = stmt.executeQuery(sql)) {
>>
>>                                 ResultSetMetaData rsmd =
>> rs.getMetaData();
>>                                 int colCount = rsmd.getColumnCount();
>>                                 int count = 1;
>>                                 try{
>>                                         while (rs.next()) {
>>                                                 //Thread.sleep(10);
>>
>>                                                 for (int i = 1; i <=
>> colCount; i++) {
>>
>> System.out.print(rsmd.getColumnName(i) + ":" + rs.getObject(i) + "
>> ");
>>                                                 }
>>                                               
>> System.out.println(count);
>>                                                 count++;
>>                                         }
>>                                 }catch(Exception e){
>>
>> System.out.println(System.currentTimeMillis()-startTime));
>>                                       
>> System.out.println(rs.isClosed());
>>
>> System.out.println(stmt.isClosed());
>>
>> System.out.println(conn.isClosed());
>>                                 }
>>
>>                         }
>>                 }
>>         }
>> }
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
yangjiajun yangjiajun
Reply | Threaded
Open this post in threaded view
|

Re: Failed to fetch SQL query result

Hello.

I think I get a reproducer for this issue:

1.Start a node with persistence enabled.
2.Create a table:CREATE TABLE city (id LONG PRIMARY KEY, name VARCHAR) WITH
"template=replicated"
3.Insert 8W random records to it.
4.Create two jdbc thin connections.
5.Start two threads using different connection repeatedly to do sacn query
and iterate the result set.
6.Then u can see the exception for a while.

Note:U can get the exception more easily when u set threadPoolSize of
clientConnectorConfiguration to 1.

Here is my test code:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class StatementTest {

        private static Connection conn;
        private static Connection conn1;

        public static void main(String[] args) throws Exception {

                initialize();

                String selectSql = "SELECT * FROM city";
                testQuery(selectSql);
                while(true){

                }
        }

        public static void close() throws Exception {
                conn.close();
        }

        public static void initialize() throws Exception {
                Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
                final String dbUrl =
"jdbc:ignite:thin://ip:port;lazy=true;skipReducerOnUpdate=true;replicatedOnly=true";
                final Properties props = new Properties();
                conn = DriverManager.getConnection(dbUrl, props);
                conn1= DriverManager.getConnection(dbUrl, props);
                //initData();
        }

        private static void initData() throws SQLException{
                for(int i=0;i<80000;i++){
                        String s=String.valueOf(Math.random());
                        conn.prepareStatement("insert into city(id,name)
VALUES("+i+","+s+")").execute();
                }
        }

        public static void testQuery(final String sql) throws Exception {

                new Thread(new Runnable() {

                        @Override
                        public void run() {
                                long startTime=System.currentTimeMillis();
                                while(true){

                                        try (Statement stmt = conn.createStatement()) {
                                                try (ResultSet rs = stmt.executeQuery(sql)) {

                                                        ResultSetMetaData rsmd = rs.getMetaData();
                                                        int colCount = rsmd.getColumnCount();
                                                        int count = 1;
                                                        try{
                                                                while (rs.next()) {
                                                                        System.out.print("conn ");
                                                                        for (int i = 1; i <= colCount; i++) {
                                                                                System.out.print(rsmd.getColumnName(i) + ":" + rs.getObject(i) + "
");
                                                                        }
                                                                        System.out.println(count);
                                                                        count++;
                                                                }
                                                        }catch(Exception e){
                                                                e.printStackTrace();
                                                                System.out.println(System.currentTimeMillis()-startTime);
                                                                System.out.println(e);
                                                                System.out.println(rs.isClosed());
                                                                System.out.println(stmt.isClosed());
                                                                System.out.println(conn.isClosed());
                                                                System.exit(-1);
                                                        }
                                                        System.out.println("test");

                                                }
                                        }catch (Exception e) {
                                                System.out.println(e);
                                        }
                                }
                        }
                }).start();
               
                new Thread(new Runnable() {

                        @Override
                        public void run() {
                                long startTime=System.currentTimeMillis();
                                while(true){

                                        try (Statement stmt = conn1.createStatement()) {
                                                try (ResultSet rs = stmt.executeQuery(sql)) {

                                                        ResultSetMetaData rsmd = rs.getMetaData();
                                                        int colCount = rsmd.getColumnCount();
                                                        int count = 1;
                                                        try{
                                                                while (rs.next()) {
                                                                        System.out.print("conn1 ");
                                                                        for (int i = 1; i <= colCount; i++) {
                                                                                System.out.print(rsmd.getColumnName(i) + ":" + rs.getObject(i) + "
");
                                                                        }
                                                                        System.out.println(count);
                                                                        count++;
                                                                }
                                                        }catch(Exception e){
                                                                e.printStackTrace();
                                                                System.out.println(System.currentTimeMillis()-startTime);
                                                                System.out.println(e);
                                                                System.out.println(rs.isClosed());
                                                                System.out.println(stmt.isClosed());
                                                                System.out.println(conn.isClosed());
                                                                System.exit(-1);
                                                        }
                                                        System.out.println("test");

                                                }
                                        }catch (Exception e) {
                                                System.out.println(e);
                                        }
                                }
                        }
                }).start();

        }
}

 


ilya.kasnacheev wrote

> Hello!
>
> Can you provide logs from your nodes prior to seeing this exceptions?
>
> Note that in a distributed system, you can expect to see this problem
> sometimes, i.e. to see a large lazy result set fail in mid-iteration due
> to
> some changes in the cluster. I'm not sure if there's nothimg more specific
> here, though.
>
> Regards,
> --
> Ilya Kasnacheev
>
>
> пн, 3 дек. 2018 г. в 06:21, yangjiajun <

> 1371549332@

>>:
>
>> Hello.
>>
>> The error does not happen every time because it disappears when we
>> restart
>> our application.But it repeats when first error appears.The row number is
>> not fixed when this error happens.We are really confused about this
>> exception.
>>
>>
>> ilya.kasnacheev wrote
>> > Hello!
>> >
>> > Does this happen every time? If so, which is the # of row on which it
>> will
>> > happen?
>> >
>> > Regards,
>> > --
>> > Ilya Kasnacheev
>> >
>> >
>> > вт, 27 нояб. 2018 г. в 10:09, yangjiajun <
>>
>> > 1371549332@
>>
>> >>:
>> >
>> >> Hello.
>> >>
>> >> I did a scan query on a table which has 8w records and tried to go
>> >> through
>> >> all records in the result set but got following exception:
>> >>
>> >> [13:53:31,523][SEVERE][client-connector-#77][JdbcRequestHandler]
>> Failed
>> >> to
>> >> fetch SQL query result [reqId=0, req=JdbcQueryFetchRequest
>> >> [queryId=38106237, pageSize=1024]]
>> >> class org.apache.ignite.internal.processors.query.IgniteSQLException:
>> The
>> >> object is already closed [90007-195]
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.fetchNext(H2ResultSetIterator.java:136)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.onHasNext(H2ResultSetIterator.java:142)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.util.GridCloseableIteratorAdapter.hasNextX(GridCloseableIteratorAdapter.java:53)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.util.lang.GridIteratorAdapter.hasNext(GridIteratorAdapter.java:45)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator.hasNext(GridQueryCacheObjectsIterator.java:61)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryCursor.fetchRows(JdbcQueryCursor.java:72)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.fetchQuery(JdbcRequestHandler.java:587)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.handle(JdbcRequestHandler.java:206)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:160)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:44)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
>> >>         at
>> >>
>> org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
>> >>         at
>> >>
>> >>
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>> >>         at
>> >>
>> >>
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>> >>         at java.lang.Thread.run(Thread.java:748)
>> >> Caused by: org.h2.jdbc.JdbcSQLException: The object is already closed
>> >> [90007-195]
>> >>         at
>> >> org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
>> >>         at org.h2.message.DbException.get(DbException.java:179)
>> >>         at org.h2.message.DbException.get(DbException.java:155)
>> >>         at org.h2.message.DbException.get(DbException.java:144)
>> >>         at
>> org.h2.jdbc.JdbcResultSet.checkClosed(JdbcResultSet.java:3208)
>> >>         at org.h2.jdbc.JdbcResultSet.next(JdbcResultSet.java:130)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.fetchNext(H2ResultSetIterator.java:110)
>> >>         ... 17 more
>> >>
>> >> My ignite version is 2.6 and I only started one node.I did not call
>> any
>> >> close methods. Why ignite closed my result set?
>> >>
>> >> Here is my test code:
>> >>
>> >> import java.sql.Connection;
>> >> import java.sql.DriverManager;
>> >> import java.sql.ResultSet;
>> >> import java.sql.ResultSetMetaData;
>> >> import java.sql.Statement;
>> >> import java.util.Properties;
>> >>
>> >> public class StatementTest {
>> >>
>> >>         private static Connection conn;
>> >>
>> >>
>> >>         public static void main(String[] args) throws Exception {
>> >>
>> >>                 long t1 = System.currentTimeMillis();
>> >>                 try {
>> >>                         initialize();
>> >>
>> >>                         String selectSql = "SELECT * FROM
>> >> table_6932_r_1_1";
>> >>                         testQuery(selectSql);
>> >>                 } catch (Exception e) {
>> >>                         throw e;
>> >>                 } finally {
>> >>                         if (conn != null)
>> >>                                 conn.close();
>> >>                 }
>> >>                 long t2 = System.currentTimeMillis();
>> >>                 System.out.println("operation costs " + (t2 - t1) + "
>> >> ms");
>> >>         }
>> >>
>> >>         public static void close() throws Exception {
>> >>                 conn.close();
>> >>         }
>> >>
>> >>         public static void initialize() throws Exception {
>> >>                
>> Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
>> >>                 String dbUrl =
>> >>
>> >>
>> "jdbc:ignite:thin://ip:port;lazy=true;skipReducerOnUpdate=true;replicatedOnly=true";
>> >>                 conn = DriverManager.getConnection(dbUrl, props);
>> >>         }
>> >>
>> >>         public static void testUpdate(String sql) throws Exception {
>> >>                 try (Statement stmt = conn.createStatement()) {
>> >>                         stmt.setQueryTimeout(10);
>> >>                         stmt.executeUpdate(sql);
>> >>                 }
>> >>         }
>> >>
>> >>         public static void testQuery(String sql) throws Exception {
>> >>                 long startTime=System.currentTimeMillis();
>> >>                 try (Statement stmt = conn.createStatement()) {
>> >>                         //stmt.setQueryTimeout(10);
>> >>                         try (ResultSet rs = stmt.executeQuery(sql)) {
>> >>
>> >>                                 ResultSetMetaData rsmd =
>> >> rs.getMetaData();
>> >>                                 int colCount = rsmd.getColumnCount();
>> >>                                 int count = 1;
>> >>                                 try{
>> >>                                         while (rs.next()) {
>> >>                                                 //Thread.sleep(10);
>> >>
>> >>                                                 for (int i = 1; i <=
>> >> colCount; i++) {
>> >>
>> >> System.out.print(rsmd.getColumnName(i) + ":" + rs.getObject(i) + "
>> >> ");
>> >>                                                 }
>> >>
>> >> System.out.println(count);
>> >>                                                 count++;
>> >>                                         }
>> >>                                 }catch(Exception e){
>> >>
>> >> System.out.println(System.currentTimeMillis()-startTime));
>> >>
>> >> System.out.println(rs.isClosed());
>> >>
>> >> System.out.println(stmt.isClosed());
>> >>
>> >> System.out.println(conn.isClosed());
>> >>                                 }
>> >>
>> >>                         }
>> >>                 }
>> >>         }
>> >> }
>> >>
>> >>
>> >>
>> >> --
>> >> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>> >>
>>
>>
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Failed to fetch SQL query result

Hello!

Why do you have setQueryTimeout here? What happens if you take it off?

Regards,
--
Ilya Kasnacheev


ср, 5 дек. 2018 г. в 09:17, yangjiajun <[hidden email]>:
Hello.

I think I get a reproducer for this issue:

1.Start a node with persistence enabled.
2.Create a table:CREATE TABLE city (id LONG PRIMARY KEY, name VARCHAR) WITH
"template=replicated"
3.Insert 8W random records to it.
4.Create two jdbc thin connections.
5.Start two threads using different connection repeatedly to do sacn query
and iterate the result set.
6.Then u can see the exception for a while.

Note:U can get the exception more easily when u set threadPoolSize of
clientConnectorConfiguration to 1.

Here is my test code:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class StatementTest {

        private static Connection conn;
        private static Connection conn1;

        public static void main(String[] args) throws Exception {

                initialize();

                String selectSql = "SELECT * FROM city";
                testQuery(selectSql);
                while(true){

                }
        }

        public static void close() throws Exception {
                conn.close();
        }

        public static void initialize() throws Exception {
                Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
                final String dbUrl =
"jdbc:ignite:thin://ip:port;lazy=true;skipReducerOnUpdate=true;replicatedOnly=true";
                final Properties props = new Properties();
                conn = DriverManager.getConnection(dbUrl, props);
                conn1= DriverManager.getConnection(dbUrl, props);
                //initData();
        }

        private static void initData() throws SQLException{
                for(int i=0;i<80000;i++){
                        String s=String.valueOf(Math.random());
                        conn.prepareStatement("insert into city(id,name)
VALUES("+i+","+s+")").execute();
                }
        }

        public static void testQuery(final String sql) throws Exception {

                new Thread(new Runnable() {

                        @Override
                        public void run() {
                                long startTime=System.currentTimeMillis();
                                while(true){

                                        try (Statement stmt = conn.createStatement()) {
                                                try (ResultSet rs = stmt.executeQuery(sql)) {

                                                        ResultSetMetaData rsmd = rs.getMetaData();
                                                        int colCount = rsmd.getColumnCount();
                                                        int count = 1;
                                                        try{
                                                                while (rs.next()) {
                                                                        System.out.print("conn ");
                                                                        for (int i = 1; i <= colCount; i++) {
                                                                                System.out.print(rsmd.getColumnName(i) + ":" + rs.getObject(i) + "
");
                                                                        }
                                                                        System.out.println(count);
                                                                        count++;
                                                                }
                                                        }catch(Exception e){
                                                                e.printStackTrace();
                                                                System.out.println(System.currentTimeMillis()-startTime);
                                                                System.out.println(e);
                                                                System.out.println(rs.isClosed());
                                                                System.out.println(stmt.isClosed());
                                                                System.out.println(conn.isClosed());
                                                                System.exit(-1);
                                                        }
                                                        System.out.println("test");

                                                }
                                        }catch (Exception e) {
                                                System.out.println(e);
                                        }
                                }
                        }
                }).start();

                new Thread(new Runnable() {

                        @Override
                        public void run() {
                                long startTime=System.currentTimeMillis();
                                while(true){

                                        try (Statement stmt = conn1.createStatement()) {
                                                try (ResultSet rs = stmt.executeQuery(sql)) {

                                                        ResultSetMetaData rsmd = rs.getMetaData();
                                                        int colCount = rsmd.getColumnCount();
                                                        int count = 1;
                                                        try{
                                                                while (rs.next()) {
                                                                        System.out.print("conn1 ");
                                                                        for (int i = 1; i <= colCount; i++) {
                                                                                System.out.print(rsmd.getColumnName(i) + ":" + rs.getObject(i) + "
");
                                                                        }
                                                                        System.out.println(count);
                                                                        count++;
                                                                }
                                                        }catch(Exception e){
                                                                e.printStackTrace();
                                                                System.out.println(System.currentTimeMillis()-startTime);
                                                                System.out.println(e);
                                                                System.out.println(rs.isClosed());
                                                                System.out.println(stmt.isClosed());
                                                                System.out.println(conn.isClosed());
                                                                System.exit(-1);
                                                        }
                                                        System.out.println("test");

                                                }
                                        }catch (Exception e) {
                                                System.out.println(e);
                                        }
                                }
                        }
                }).start();

        }
}




ilya.kasnacheev wrote
> Hello!
>
> Can you provide logs from your nodes prior to seeing this exceptions?
>
> Note that in a distributed system, you can expect to see this problem
> sometimes, i.e. to see a large lazy result set fail in mid-iteration due
> to
> some changes in the cluster. I'm not sure if there's nothimg more specific
> here, though.
>
> Regards,
> --
> Ilya Kasnacheev
>
>
> пн, 3 дек. 2018 г. в 06:21, yangjiajun <

> 1371549332@

>>:
>
>> Hello.
>>
>> The error does not happen every time because it disappears when we
>> restart
>> our application.But it repeats when first error appears.The row number is
>> not fixed when this error happens.We are really confused about this
>> exception.
>>
>>
>> ilya.kasnacheev wrote
>> > Hello!
>> >
>> > Does this happen every time? If so, which is the # of row on which it
>> will
>> > happen?
>> >
>> > Regards,
>> > --
>> > Ilya Kasnacheev
>> >
>> >
>> > вт, 27 нояб. 2018 г. в 10:09, yangjiajun <
>>
>> > 1371549332@
>>
>> >>:
>> >
>> >> Hello.
>> >>
>> >> I did a scan query on a table which has 8w records and tried to go
>> >> through
>> >> all records in the result set but got following exception:
>> >>
>> >> [13:53:31,523][SEVERE][client-connector-#77][JdbcRequestHandler]
>> Failed
>> >> to
>> >> fetch SQL query result [reqId=0, req=JdbcQueryFetchRequest
>> >> [queryId=38106237, pageSize=1024]]
>> >> class org.apache.ignite.internal.processors.query.IgniteSQLException:
>> The
>> >> object is already closed [90007-195]
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.fetchNext(H2ResultSetIterator.java:136)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.onHasNext(H2ResultSetIterator.java:142)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.util.GridCloseableIteratorAdapter.hasNextX(GridCloseableIteratorAdapter.java:53)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.util.lang.GridIteratorAdapter.hasNext(GridIteratorAdapter.java:45)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator.hasNext(GridQueryCacheObjectsIterator.java:61)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.odbc.jdbc.JdbcQueryCursor.fetchRows(JdbcQueryCursor.java:72)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.fetchQuery(JdbcRequestHandler.java:587)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.handle(JdbcRequestHandler.java:206)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:160)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:44)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97)
>> >>         at
>> >>
>> org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70)
>> >>         at
>> >>
>> >>
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>> >>         at
>> >>
>> >>
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>> >>         at java.lang.Thread.run(Thread.java:748)
>> >> Caused by: org.h2.jdbc.JdbcSQLException: The object is already closed
>> >> [90007-195]
>> >>         at
>> >> org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
>> >>         at org.h2.message.DbException.get(DbException.java:179)
>> >>         at org.h2.message.DbException.get(DbException.java:155)
>> >>         at org.h2.message.DbException.get(DbException.java:144)
>> >>         at
>> org.h2.jdbc.JdbcResultSet.checkClosed(JdbcResultSet.java:3208)
>> >>         at org.h2.jdbc.JdbcResultSet.next(JdbcResultSet.java:130)
>> >>         at
>> >>
>> >>
>> org.apache.ignite.internal.processors.query.h2.H2ResultSetIterator.fetchNext(H2ResultSetIterator.java:110)
>> >>         ... 17 more
>> >>
>> >> My ignite version is 2.6 and I only started one node.I did not call
>> any
>> >> close methods. Why ignite closed my result set?
>> >>
>> >> Here is my test code:
>> >>
>> >> import java.sql.Connection;
>> >> import java.sql.DriverManager;
>> >> import java.sql.ResultSet;
>> >> import java.sql.ResultSetMetaData;
>> >> import java.sql.Statement;
>> >> import java.util.Properties;
>> >>
>> >> public class StatementTest {
>> >>
>> >>         private static Connection conn;
>> >>
>> >>
>> >>         public static void main(String[] args) throws Exception {
>> >>
>> >>                 long t1 = System.currentTimeMillis();
>> >>                 try {
>> >>                         initialize();
>> >>
>> >>                         String selectSql = "SELECT * FROM
>> >> table_6932_r_1_1";
>> >>                         testQuery(selectSql);
>> >>                 } catch (Exception e) {
>> >>                         throw e;
>> >>                 } finally {
>> >>                         if (conn != null)
>> >>                                 conn.close();
>> >>                 }
>> >>                 long t2 = System.currentTimeMillis();
>> >>                 System.out.println("operation costs " + (t2 - t1) + "
>> >> ms");
>> >>         }
>> >>
>> >>         public static void close() throws Exception {
>> >>                 conn.close();
>> >>         }
>> >>
>> >>         public static void initialize() throws Exception {
>> >>               
>> Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
>> >>                 String dbUrl =
>> >>
>> >>
>> "jdbc:ignite:thin://ip:port;lazy=true;skipReducerOnUpdate=true;replicatedOnly=true";
>> >>                 conn = DriverManager.getConnection(dbUrl, props);
>> >>         }
>> >>
>> >>         public static void testUpdate(String sql) throws Exception {
>> >>                 try (Statement stmt = conn.createStatement()) {
>> >>                         stmt.setQueryTimeout(10);
>> >>                         stmt.executeUpdate(sql);
>> >>                 }
>> >>         }
>> >>
>> >>         public static void testQuery(String sql) throws Exception {
>> >>                 long startTime=System.currentTimeMillis();
>> >>                 try (Statement stmt = conn.createStatement()) {
>> >>                         //stmt.setQueryTimeout(10);
>> >>                         try (ResultSet rs = stmt.executeQuery(sql)) {
>> >>
>> >>                                 ResultSetMetaData rsmd =
>> >> rs.getMetaData();
>> >>                                 int colCount = rsmd.getColumnCount();
>> >>                                 int count = 1;
>> >>                                 try{
>> >>                                         while (rs.next()) {
>> >>                                                 //Thread.sleep(10);
>> >>
>> >>                                                 for (int i = 1; i <=
>> >> colCount; i++) {
>> >>
>> >> System.out.print(rsmd.getColumnName(i) + ":" + rs.getObject(i) + "
>> >> ");
>> >>                                                 }
>> >>
>> >> System.out.println(count);
>> >>                                                 count++;
>> >>                                         }
>> >>                                 }catch(Exception e){
>> >>
>> >> System.out.println(System.currentTimeMillis()-startTime));
>> >>
>> >> System.out.println(rs.isClosed());
>> >>
>> >> System.out.println(stmt.isClosed());
>> >>
>> >> System.out.println(conn.isClosed());
>> >>                                 }
>> >>
>> >>                         }
>> >>                 }
>> >>         }
>> >> }
>> >>
>> >>
>> >>
>> >> --
>> >> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>> >>
>>
>>
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
yangjiajun yangjiajun
Reply | Threaded
Open this post in threaded view
|

Re: Failed to fetch SQL query result

Hello.

I test setQueryTimeout method  to see whether it works or not because I try
to prevent long time queries from blocking other operations.According to my
test,this method has no effect.You can also see that I have already removed
it in my latest test code.The code is simple and reproduce my issue.


Hello!

Why do you have setQueryTimeout here? What happens if you take it off?

Regards,
--
Ilya Kasnacheev


ср, 5 дек. 2018 г. в 09:17, yangjiajun <1371549332@>:




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Failed to fetch SQL query result

Hello!

I have confirmed this problem and we are working on it in https://issues.apache.org/jira/browse/IGNITE-9171
I have converted your reproducer to Ignite test, hope you don't mind.

There is a workaround in that you could add a parameter to your query, such as WHERE id > ?, and pass something like -1 to bind to this parameter, which should prevent the issue from occurring.

Regards,
--
Ilya Kasnacheev


ср, 5 дек. 2018 г. в 16:21, yangjiajun <[hidden email]>:
Hello.

I test setQueryTimeout method  to see whether it works or not because I try
to prevent long time queries from blocking other operations.According to my
test,this method has no effect.You can also see that I have already removed
it in my latest test code.The code is simple and reproduce my issue.


Hello!

Why do you have setQueryTimeout here? What happens if you take it off?

Regards,
--
Ilya Kasnacheev


ср, 5 дек. 2018 г. в 09:17, yangjiajun <1371549332@>:




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
yangjiajun yangjiajun
Reply | Threaded
Open this post in threaded view
|

Re: Failed to fetch SQL query result

Hello!

Please fell free to deal with the code.

I try to add where clause to my query,but it does not save me.The test code
still throws the exception after a while.My ignite's version is 2.6.Does the
workaround work in latest version?Or does this workaround only reduce the
probability of the issue?


ilya.kasnacheev wrote

> Hello!
>
> I have confirmed this problem and we are working on it in
> https://issues.apache.org/jira/browse/IGNITE-9171
> I have converted your reproducer to Ignite test, hope you don't mind.
>
> There is a workaround in that you could add a parameter to your query,
> such
> as WHERE id > ?, and pass something like -1 to bind to this parameter,
> which should prevent the issue from occurring.
>
> Regards,
> --
> Ilya Kasnacheev
>
>
> ср, 5 дек. 2018 г. в 16:21, yangjiajun <

> 1371549332@

>>:
>
>> Hello.
>>
>> I test setQueryTimeout method  to see whether it works or not because I
>> try
>> to prevent long time queries from blocking other operations.According to
>> my
>> test,this method has no effect.You can also see that I have already
>> removed
>> it in my latest test code.The code is simple and reproduce my issue.
>>
>>
>> Hello!
>>
>> Why do you have setQueryTimeout here? What happens if you take it off?
>>
>> Regards,
>> --
>> Ilya Kasnacheev
>>
>>
>> ср, 5 дек. 2018 г. в 09:17, yangjiajun <1371549332@>:
>>
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Failed to fetch SQL query result

Hello!

After more investigation we have opened a new ticket:
And the workaround is different: you need to make query non-local, for example by turning cache partitioned instead of replicated.
If you execute two identical local queries (ones that query planner considers such) you will get into such problems.

You can also drop lazy=false for now.

Regards,
--
Ilya Kasnacheev


пт, 7 дек. 2018 г. в 06:56, yangjiajun <[hidden email]>:
Hello!

Please fell free to deal with the code.

I try to add where clause to my query,but it does not save me.The test code
still throws the exception after a while.My ignite's version is 2.6.Does the
workaround work in latest version?Or does this workaround only reduce the
probability of the issue?


ilya.kasnacheev wrote
> Hello!
>
> I have confirmed this problem and we are working on it in
> https://issues.apache.org/jira/browse/IGNITE-9171
> I have converted your reproducer to Ignite test, hope you don't mind.
>
> There is a workaround in that you could add a parameter to your query,
> such
> as WHERE id > ?, and pass something like -1 to bind to this parameter,
> which should prevent the issue from occurring.
>
> Regards,
> --
> Ilya Kasnacheev
>
>
> ср, 5 дек. 2018 г. в 16:21, yangjiajun <

> 1371549332@

>>:
>
>> Hello.
>>
>> I test setQueryTimeout method  to see whether it works or not because I
>> try
>> to prevent long time queries from blocking other operations.According to
>> my
>> test,this method has no effect.You can also see that I have already
>> removed
>> it in my latest test code.The code is simple and reproduce my issue.
>>
>>
>> Hello!
>>
>> Why do you have setQueryTimeout here? What happens if you take it off?
>>
>> Regards,
>> --
>> Ilya Kasnacheev
>>
>>
>> ср, 5 дек. 2018 г. в 09:17, yangjiajun <1371549332@>:
>>
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/