ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ipavluk...@apache.org
Subject [ignite] branch ignite-2.8 updated: IGNITE-12424 Fix broken default query timeout support for thin JDBC driver by making this timeout effectively unsupported for thin JDBC - Fixes #7122.
Date Tue, 17 Dec 2019 12:28:31 GMT
This is an automated email from the ASF dual-hosted git repository.

ipavlukhin pushed a commit to branch ignite-2.8
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/ignite-2.8 by this push:
     new 4836d3c  IGNITE-12424 Fix broken default query timeout support for thin JDBC driver
by making this timeout effectively unsupported for thin JDBC - Fixes #7122.
4836d3c is described below

commit 4836d3cafd2cc53332f15c9b257b481f5c69883f
Author: ipavlukhin <vololo100@gmail.com>
AuthorDate: Tue Dec 17 11:22:47 2019 +0300

    IGNITE-12424 Fix broken default query timeout support for thin JDBC
    driver by making this timeout effectively unsupported for thin JDBC - Fixes #7122.
    
    Signed-off-by: ipavlukhin <vololo100@gmail.com>
    (cherry picked from commit 8eafafe7c370abff907684e7956588af9d66d752)
---
 .../jdbc/suite/IgniteJdbcDriverTestSuite.java      |   2 +
 .../jdbc/thin/JdbcThinDefaultTimeoutTest.java      | 109 +++++++++++++++++++++
 .../processors/odbc/jdbc/JdbcRequestHandler.java   |   2 +
 3 files changed, 113 insertions(+)

diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
b/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
index 62ec8af..0b23c9c 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/suite/IgniteJdbcDriverTestSuite.java
@@ -55,6 +55,7 @@ import org.apache.ignite.jdbc.thin.JdbcThinConnectionSelfTest;
 import org.apache.ignite.jdbc.thin.JdbcThinConnectionTimeoutSelfTest;
 import org.apache.ignite.jdbc.thin.JdbcThinDataPageScanPropertySelfTest;
 import org.apache.ignite.jdbc.thin.JdbcThinDataSourceSelfTest;
+import org.apache.ignite.jdbc.thin.JdbcThinDefaultTimeoutTest;
 import org.apache.ignite.jdbc.thin.JdbcThinDeleteStatementSelfTest;
 import org.apache.ignite.jdbc.thin.JdbcThinDynamicIndexAtomicPartitionedNearSelfTest;
 import org.apache.ignite.jdbc.thin.JdbcThinDynamicIndexAtomicPartitionedSelfTest;
@@ -179,6 +180,7 @@ import org.junit.runners.Suite;
     JdbcThinStatementCancelSelfTest.class,
     JdbcThinStatementTimeoutSelfTest.class,
     JdbcThinConnectionTimeoutSelfTest.class,
+    JdbcThinDefaultTimeoutTest.class,
 
     JdbcThinInsertStatementSelfTest.class,
     JdbcThinUpdateStatementSelfTest.class,
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDefaultTimeoutTest.java
b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDefaultTimeoutTest.java
new file mode 100644
index 0000000..40bb9a6
--- /dev/null
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinDefaultTimeoutTest.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.jdbc.thin;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.ignite.cache.query.annotations.QuerySqlFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+/** */
+public class JdbcThinDefaultTimeoutTest extends GridCommonAbstractTest {
+    /** */
+    public static final int ROW_COUNT = 200;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws
Exception {
+        CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME)
+            .setIndexedTypes(Integer.class, Integer.class)
+            .setSqlSchema("PUBLIC")
+            .setSqlFunctionClasses(TestSQLFunctions.class);
+
+        return super.getConfiguration(igniteInstanceName)
+            .setCacheConfiguration(ccfg)
+            .setDefaultQueryTimeout(100);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        IgniteEx ign = startGrid(0);
+
+        Map<Integer, Integer> vals = IntStream.range(0, ROW_COUNT)
+            .boxed()
+            .collect(Collectors.toMap(Function.identity(), Function.identity()));
+
+        // We need to fill cache with many rows because server-side timeout checks for timeout
periodically after
+        // loading several rows.
+        ign.cache(DEFAULT_CACHE_NAME).putAll(vals);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+
+        super.afterTestsStopped();
+    }
+
+    /** */
+    @Test
+    public void testDefaultTimeoutIgnored() throws Exception {
+        try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://localhost"))
{
+            Statement stmt = conn.createStatement();
+
+            ResultSet rs = stmt.executeQuery("select _key, _val, sleepFunc(5) from Integer");
+
+            int cnt = 0;
+            while (rs.next())
+                cnt++;
+
+            assertEquals(ROW_COUNT, cnt);
+
+            // assert no exception
+        }
+    }
+
+    /**
+     * Utility class with custom SQL functions.
+     */
+    public static class TestSQLFunctions {
+        /** */
+        @QuerySqlFunction
+        public static int sleepFunc(int v) {
+            try {
+                Thread.sleep(v);
+            }
+            catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+            }
+
+            return v;
+        }
+    }
+}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
index 1050283..0bb89d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
@@ -30,6 +30,7 @@ import java.util.Set;
 import java.util.SortedSet;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
 import javax.cache.configuration.Factory;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
@@ -970,6 +971,7 @@ public class JdbcRequestHandler implements ClientListenerRequestHandler
{
         qry.setLazy(cliCtx.isLazy());
         qry.setNestedTxMode(nestedTxMode);
         qry.setSchema(schemaName);
+        qry.setTimeout(0, TimeUnit.MILLISECONDS);
 
         if (cliCtx.updateBatchSize() != null)
             qry.setUpdateBatchSize(cliCtx.updateBatchSize());


Mime
View raw message