You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/09/03 10:12:14 UTC

[GitHub] [ignite] NSAmelchev opened a new pull request #9376: IGNITE-15346 Iterator of the ClientCacheQueryCursor can be closed during serialization.

NSAmelchev opened a new pull request #9376:
URL: https://github.com/apache/ignite/pull/9376


   - Fix error message of closed iterator.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] alex-plekhanov commented on a change in pull request #9376: IGNITE-15346 Iterator of the ClientCacheQueryCursor can be closed during serialization.

Posted by GitBox <gi...@apache.org>.
alex-plekhanov commented on a change in pull request #9376:
URL: https://github.com/apache/ignite/pull/9376#discussion_r704107362



##########
File path: modules/core/src/test/java/org/apache/ignite/client/ScanQueryCloseTest.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.client;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.QueryMXBeanImpl;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.mxbean.QueryMXBean;
+import org.apache.ignite.spi.systemview.view.ScanQueryView;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause;
+
+/**
+ * Tests scan query close.
+ */
+public class ScanQueryCloseTest extends GridCommonAbstractTest {
+    /** Test logger. */
+    private ListeningTestLogger testLog = new ListeningTestLogger(log);
+
+    /** Query filter latch. */
+    private static CountDownLatch filterLatch = new CountDownLatch(1);

Review comment:
       final

##########
File path: modules/core/src/test/java/org/apache/ignite/client/ScanQueryCloseTest.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.client;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.QueryMXBeanImpl;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.mxbean.QueryMXBean;
+import org.apache.ignite.spi.systemview.view.ScanQueryView;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause;
+
+/**
+ * Tests scan query close.
+ */
+public class ScanQueryCloseTest extends GridCommonAbstractTest {

Review comment:
       Test not included to any suite

##########
File path: modules/core/src/test/java/org/apache/ignite/client/ScanQueryCloseTest.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.client;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.QueryMXBeanImpl;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.mxbean.QueryMXBean;
+import org.apache.ignite.spi.systemview.view.ScanQueryView;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause;
+
+/**
+ * Tests scan query close.
+ */
+public class ScanQueryCloseTest extends GridCommonAbstractTest {
+    /** Test logger. */
+    private ListeningTestLogger testLog = new ListeningTestLogger(log);
+
+    /** Query filter latch. */
+    private static CountDownLatch filterLatch = new CountDownLatch(1);
+
+    /** @throws Exception If failed. */
+    @Test
+    public void testScanQueryClose() throws Exception {
+        try (Ignite srv1 = Ignition.start(Config.getServerConfiguration().setGridLogger(testLog));
+             Ignite srv2 = Ignition.start(Config.getServerConfiguration().setGridLogger(testLog));
+
+             IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER))
+        ) {
+            ClientCache<Object, Object> cache = client.getOrCreateCache(DEFAULT_CACHE_NAME);
+
+            for (int i = 0; i < 10; i++)
+                cache.put(i, i);
+
+            ScanQuery<Object, Object> qry = new ScanQuery<>().setFilter((o, o2) -> {
+                try {
+                    filterLatch.countDown();
+
+                    U.sleep(1000);
+                }
+                catch (IgniteInterruptedCheckedException ignored) {
+                    // No-op.
+                }
+
+                return true;
+            });
+
+            LogListener lsnr = LogListener.matches("Iterator has been closed.").build();
+
+            testLog.registerListener(lsnr);
+
+            IgniteInternalFuture<?> fut = GridTestUtils.runAsync(() -> {
+                cache.query(qry).getAll();
+            });
+
+            filterLatch.await(getTestTimeout(), TimeUnit.SECONDS);
+
+            killQueries();
+
+            assertThrowsAnyCause(log, fut::get, IgniteCheckedException.class, null);

Review comment:
       `IgniteCheckedException` it's a wrapper exception, thin client doesn't use such exception, `ClientException` is used instead. Let's assert `ClientException.class` here.

##########
File path: modules/core/src/test/java/org/apache/ignite/client/ScanQueryCloseTest.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.client;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.QueryMXBeanImpl;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.mxbean.QueryMXBean;
+import org.apache.ignite.spi.systemview.view.ScanQueryView;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause;
+
+/**
+ * Tests scan query close.
+ */
+public class ScanQueryCloseTest extends GridCommonAbstractTest {
+    /** Test logger. */
+    private ListeningTestLogger testLog = new ListeningTestLogger(log);

Review comment:
       final

##########
File path: modules/core/src/test/java/org/apache/ignite/client/ScanQueryCloseTest.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.client;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.QueryMXBeanImpl;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.mxbean.QueryMXBean;
+import org.apache.ignite.spi.systemview.view.ScanQueryView;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause;
+
+/**
+ * Tests scan query close.
+ */
+public class ScanQueryCloseTest extends GridCommonAbstractTest {
+    /** Test logger. */
+    private ListeningTestLogger testLog = new ListeningTestLogger(log);
+
+    /** Query filter latch. */
+    private static CountDownLatch filterLatch = new CountDownLatch(1);
+
+    /** @throws Exception If failed. */
+    @Test
+    public void testScanQueryClose() throws Exception {
+        try (Ignite srv1 = Ignition.start(Config.getServerConfiguration().setGridLogger(testLog));
+             Ignite srv2 = Ignition.start(Config.getServerConfiguration().setGridLogger(testLog));
+
+             IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER))
+        ) {
+            ClientCache<Object, Object> cache = client.getOrCreateCache(DEFAULT_CACHE_NAME);
+
+            for (int i = 0; i < 10; i++)
+                cache.put(i, i);
+
+            ScanQuery<Object, Object> qry = new ScanQuery<>().setFilter((o, o2) -> {
+                try {
+                    filterLatch.countDown();
+
+                    U.sleep(1000);

Review comment:
       Let's wait for another latch here (CountDown it after killQueries), in the current implementation we are waiting for each key (on each node) and this brings additional delay to test (about 5 keys per node - 5 seconds delay)  

##########
File path: modules/core/src/test/java/org/apache/ignite/client/ScanQueryCloseTest.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.client;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.QueryMXBeanImpl;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.mxbean.QueryMXBean;
+import org.apache.ignite.spi.systemview.view.ScanQueryView;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause;
+
+/**
+ * Tests scan query close.
+ */
+public class ScanQueryCloseTest extends GridCommonAbstractTest {
+    /** Test logger. */
+    private ListeningTestLogger testLog = new ListeningTestLogger(log);
+
+    /** Query filter latch. */
+    private static CountDownLatch filterLatch = new CountDownLatch(1);
+
+    /** @throws Exception If failed. */
+    @Test
+    public void testScanQueryClose() throws Exception {
+        try (Ignite srv1 = Ignition.start(Config.getServerConfiguration().setGridLogger(testLog));
+             Ignite srv2 = Ignition.start(Config.getServerConfiguration().setGridLogger(testLog));
+
+             IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER))
+        ) {
+            ClientCache<Object, Object> cache = client.getOrCreateCache(DEFAULT_CACHE_NAME);
+
+            for (int i = 0; i < 10; i++)
+                cache.put(i, i);
+
+            ScanQuery<Object, Object> qry = new ScanQuery<>().setFilter((o, o2) -> {
+                try {
+                    filterLatch.countDown();
+
+                    U.sleep(1000);
+                }
+                catch (IgniteInterruptedCheckedException ignored) {
+                    // No-op.
+                }
+
+                return true;
+            });
+
+            LogListener lsnr = LogListener.matches("Iterator has been closed.").build();
+
+            testLog.registerListener(lsnr);
+
+            IgniteInternalFuture<?> fut = GridTestUtils.runAsync(() -> {
+                cache.query(qry).getAll();
+            });
+
+            filterLatch.await(getTestTimeout(), TimeUnit.SECONDS);
+
+            killQueries();
+
+            assertThrowsAnyCause(log, fut::get, IgniteCheckedException.class, null);
+
+            assertTrue(lsnr.check());
+        }
+    }
+
+    /** Kill all queries. */
+    private static void killQueries() {
+        List<Ignite> srvs = G.allGrids();
+
+        assertFalse(srvs.isEmpty());
+
+        QueryMXBean bean = getMxBean(srvs.get(0).name(), "Query",
+            QueryMXBeanImpl.class.getSimpleName(), QueryMXBean.class);
+
+        for (IgniteEx ignite : F.transform(G.allGrids(), ignite -> (IgniteEx)ignite)) {

Review comment:
       Perhaps we can connect to only one server node by thin client to simplify the test (kill all queries only on node we are connected to) 

##########
File path: modules/core/src/test/java/org/apache/ignite/client/ScanQueryCloseTest.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.client;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.QueryMXBeanImpl;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.mxbean.QueryMXBean;
+import org.apache.ignite.spi.systemview.view.ScanQueryView;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.managers.systemview.ScanQuerySystemView.SCAN_QRY_SYS_VIEW;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause;
+
+/**
+ * Tests scan query close.
+ */
+public class ScanQueryCloseTest extends GridCommonAbstractTest {
+    /** Test logger. */
+    private ListeningTestLogger testLog = new ListeningTestLogger(log);
+
+    /** Query filter latch. */
+    private static CountDownLatch filterLatch = new CountDownLatch(1);
+
+    /** @throws Exception If failed. */
+    @Test
+    public void testScanQueryClose() throws Exception {
+        try (Ignite srv1 = Ignition.start(Config.getServerConfiguration().setGridLogger(testLog));

Review comment:
       Let's use test frameworks `startGrids(2)` with `getConfiguration` overriden to start server nodes (it works faster) and use `AbstractThinClientTest.startClient` to start thin client.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] NSAmelchev merged pull request #9376: IGNITE-15346 Iterator of the ClientCacheQueryCursor can be closed during serialization.

Posted by GitBox <gi...@apache.org>.
NSAmelchev merged pull request #9376:
URL: https://github.com/apache/ignite/pull/9376


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] NSAmelchev commented on a change in pull request #9376: IGNITE-15346 Iterator of the ClientCacheQueryCursor can be closed during serialization.

Posted by GitBox <gi...@apache.org>.
NSAmelchev commented on a change in pull request #9376:
URL: https://github.com/apache/ignite/pull/9376#discussion_r707041282



##########
File path: modules/indexing/src/test/java/org/apache/ignite/util/KillCommandsTests.java
##########
@@ -82,14 +87,35 @@
     /** Latch to block compute task execution. */
     private static CountDownLatch computeLatch;
 
+    /** Scan query filter latch. */
+    private static CountDownLatch filterLatch;

Review comment:
       Fixed, thanks.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] alex-plekhanov commented on a change in pull request #9376: IGNITE-15346 Iterator of the ClientCacheQueryCursor can be closed during serialization.

Posted by GitBox <gi...@apache.org>.
alex-plekhanov commented on a change in pull request #9376:
URL: https://github.com/apache/ignite/pull/9376#discussion_r706154230



##########
File path: modules/indexing/src/test/java/org/apache/ignite/util/KillCommandsTests.java
##########
@@ -128,6 +154,68 @@ public static void doTestScanQueryCancel(IgniteEx cli, List<IgniteEx> srvs, Cons
         for (int i = 0; i < PAGE_SZ * PAGE_SZ - 1; i++)
             assertNotNull(iter2.next());
 
+        checkScanQueryResources(cli, srvs, qryId);
+
+        qry2.close();
+    }
+
+    /**
+     * Checks cancel of the scan query during fetching.
+     *
+     * @param cli Client node.
+     * @param srvs Server nodes.
+     * @param qryCanceler Query cancel closure.
+     */
+    private static void checkScanQueryCancelDuringFetching(IgniteEx cli, List<IgniteEx> srvs,
+        Consumer<T3<UUID, String, Long>> qryCanceler) throws Exception {
+        filterLatch = new CountDownLatch(1);
+        cancelLatch = new CountDownLatch(1);
+
+        IgniteCache<Object, Object> cache = cli.cache(DEFAULT_CACHE_NAME);
+
+        QueryCursor<Cache.Entry<Object, Object>> qry = cache.query(new ScanQuery<>().setFilter((o, o2) -> {
+            try {
+                filterLatch.countDown();
+
+                cancelLatch.await(TIMEOUT, TimeUnit.MILLISECONDS);
+            }
+            catch (Exception ignored) {
+                // No-op.
+            }
+
+            return true;
+        }));
+
+        IgniteInternalFuture<?> fut = GridTestUtils.runAsync((Runnable)() -> qry.iterator().next());
+
+        assertTrue(filterLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));
+
+        List<List<?>> scanQries0 = execute(srvs.get(0),
+            "SELECT ORIGIN_NODE_ID, CACHE_NAME, QUERY_ID FROM SYS.SCAN_QUERIES");
+
+        assertEquals(1, scanQries0.size());
+
+        UUID originNodeId = (UUID)scanQries0.get(0).get(0);
+        String cacheName = (String)scanQries0.get(0).get(1);
+        long qryId = (Long)scanQries0.get(0).get(2);

Review comment:
       Deduplicate?

##########
File path: modules/indexing/src/test/java/org/apache/ignite/util/KillCommandsTests.java
##########
@@ -82,14 +87,35 @@
     /** Latch to block compute task execution. */
     private static CountDownLatch computeLatch;
 
+    /** Scan query filter latch. */
+    private static CountDownLatch filterLatch;

Review comment:
       volatile?

##########
File path: modules/indexing/src/test/java/org/apache/ignite/util/KillCommandsTests.java
##########
@@ -82,14 +87,35 @@
     /** Latch to block compute task execution. */
     private static CountDownLatch computeLatch;
 
+    /** Scan query filter latch. */
+    private static CountDownLatch filterLatch;
+
+    /** Scan query cancel latch. */
+    private static CountDownLatch cancelLatch;
+
     /**
      * Test cancel of the scan query.
      *
      * @param cli Client node.
      * @param srvs Server nodes.
      * @param qryCanceler Query cancel closure.
      */
-    public static void doTestScanQueryCancel(IgniteEx cli, List<IgniteEx> srvs, Consumer<T3<UUID, String, Long>> qryCanceler) {
+    public static void doTestScanQueryCancel(IgniteEx cli, List<IgniteEx> srvs,

Review comment:
       Arguments declaration should be all in one line, or each argument on a separate line according to code style.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] NSAmelchev commented on a change in pull request #9376: IGNITE-15346 Iterator of the ClientCacheQueryCursor can be closed during serialization.

Posted by GitBox <gi...@apache.org>.
NSAmelchev commented on a change in pull request #9376:
URL: https://github.com/apache/ignite/pull/9376#discussion_r707041108



##########
File path: modules/indexing/src/test/java/org/apache/ignite/util/KillCommandsTests.java
##########
@@ -128,6 +154,68 @@ public static void doTestScanQueryCancel(IgniteEx cli, List<IgniteEx> srvs, Cons
         for (int i = 0; i < PAGE_SZ * PAGE_SZ - 1; i++)
             assertNotNull(iter2.next());
 
+        checkScanQueryResources(cli, srvs, qryId);
+
+        qry2.close();
+    }
+
+    /**
+     * Checks cancel of the scan query during fetching.
+     *
+     * @param cli Client node.
+     * @param srvs Server nodes.
+     * @param qryCanceler Query cancel closure.
+     */
+    private static void checkScanQueryCancelDuringFetching(IgniteEx cli, List<IgniteEx> srvs,
+        Consumer<T3<UUID, String, Long>> qryCanceler) throws Exception {
+        filterLatch = new CountDownLatch(1);
+        cancelLatch = new CountDownLatch(1);
+
+        IgniteCache<Object, Object> cache = cli.cache(DEFAULT_CACHE_NAME);
+
+        QueryCursor<Cache.Entry<Object, Object>> qry = cache.query(new ScanQuery<>().setFilter((o, o2) -> {
+            try {
+                filterLatch.countDown();
+
+                cancelLatch.await(TIMEOUT, TimeUnit.MILLISECONDS);
+            }
+            catch (Exception ignored) {
+                // No-op.
+            }
+
+            return true;
+        }));
+
+        IgniteInternalFuture<?> fut = GridTestUtils.runAsync((Runnable)() -> qry.iterator().next());
+
+        assertTrue(filterLatch.await(TIMEOUT, TimeUnit.MILLISECONDS));
+
+        List<List<?>> scanQries0 = execute(srvs.get(0),
+            "SELECT ORIGIN_NODE_ID, CACHE_NAME, QUERY_ID FROM SYS.SCAN_QUERIES");
+
+        assertEquals(1, scanQries0.size());
+
+        UUID originNodeId = (UUID)scanQries0.get(0).get(0);
+        String cacheName = (String)scanQries0.get(0).get(1);
+        long qryId = (Long)scanQries0.get(0).get(2);

Review comment:
       Fixed.

##########
File path: modules/indexing/src/test/java/org/apache/ignite/util/KillCommandsTests.java
##########
@@ -82,14 +87,35 @@
     /** Latch to block compute task execution. */
     private static CountDownLatch computeLatch;
 
+    /** Scan query filter latch. */
+    private static CountDownLatch filterLatch;
+
+    /** Scan query cancel latch. */
+    private static CountDownLatch cancelLatch;
+
     /**
      * Test cancel of the scan query.
      *
      * @param cli Client node.
      * @param srvs Server nodes.
      * @param qryCanceler Query cancel closure.
      */
-    public static void doTestScanQueryCancel(IgniteEx cli, List<IgniteEx> srvs, Consumer<T3<UUID, String, Long>> qryCanceler) {
+    public static void doTestScanQueryCancel(IgniteEx cli, List<IgniteEx> srvs,

Review comment:
       Fixed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org