This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 8b4b9327a55 IGNITE-28757 Fix node failure on exception in 
ContinuousQuery - Fixes #13222.
8b4b9327a55 is described below

commit 8b4b9327a5578ac3dab5a1ff51c28f1f7ce7b143
Author: Aleksey Plekhanov <[email protected]>
AuthorDate: Wed Jun 10 15:25:44 2026 +0500

    IGNITE-28757 Fix node failure on exception in ContinuousQuery - Fixes 
#13222.
    
    Signed-off-by: Aleksey Plekhanov <[email protected]>
---
 .../continuous/CacheContinuousQueryHandler.java    |  19 ++-
 .../ContinuousQueryUserCodeExceptionTest.java      | 145 +++++++++++++++++++++
 .../testsuites/IgniteCacheQuerySelfTestSuite6.java |   2 +
 3 files changed, 159 insertions(+), 7 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index 28f941a4cba..eca4f12544b 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -1132,7 +1132,7 @@ public class CacheContinuousQueryHandler<K, V> implements 
GridContinuousHandler
         catch (NoClassDefFoundError e) {
             P2PClassLoadingIssues.rethrowDisarmedP2PClassLoadingFailure(e);
         }
-        catch (Exception e) {
+        catch (Throwable e) {
             U.error(log, "CacheEntryEventFilter failed: " + e);
         }
 
@@ -1251,11 +1251,16 @@ public class CacheContinuousQueryHandler<K, V> 
implements GridContinuousHandler
         if (F.isEmpty(evts))
             return;
 
-        if (locLsnr != null)
-            locLsnr.onUpdated(evts);
+        try {
+            if (locLsnr != null)
+                locLsnr.onUpdated(evts);
 
-        if (locTransLsnr != null)
-            locTransLsnr.onUpdated(transform(trans, evts));
+            if (locTransLsnr != null)
+                locTransLsnr.onUpdated(transform(trans, evts));
+        }
+        catch (Throwable e) {
+            log.warning("Failed to invoke continues query listener", e);
+        }
     }
 
     /**
@@ -1800,8 +1805,8 @@ public class CacheContinuousQueryHandler<K, V> implements 
GridContinuousHandler
         catch (NoClassDefFoundError e) {
             P2PClassLoadingIssues.rethrowDisarmedP2PClassLoadingFailure(e);
         }
-        catch (Exception e) {
-            U.error(log, e);
+        catch (Throwable e) {
+            U.error(log, "Failed to transform entry", e);
         }
 
         return transVal;
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryUserCodeExceptionTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryUserCodeExceptionTest.java
new file mode 100644
index 00000000000..97d8a7a20b9
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/ContinuousQueryUserCodeExceptionTest.java
@@ -0,0 +1,145 @@
+/*
+ * 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.internal.processors.cache.query.continuous;
+
+import java.util.Collection;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.query.AbstractContinuousQuery;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cache.query.ContinuousQueryWithTransformer;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.testframework.GridTestUtils.cartesianProduct;
+
+/** Tests that exception in user code of ContinuousQuery doesn't affect 
transactions or node functionality. */
+@RunWith(Parameterized.class)
+public class ContinuousQueryUserCodeExceptionTest extends 
GridCommonAbstractTest {
+    /** */
+    @Parameterized.Parameter
+    public CacheMode cacheMode;
+
+    /** */
+    @Parameterized.Parameter(1)
+    public CacheAtomicityMode cacheAtomicity;
+
+    /** */
+    @Parameterized.Parameter(2)
+    public boolean locQry;
+
+    /** */
+    @Parameterized.Parameters(name = "cacheMode={0}, atomicityMode={1}, 
local={2}")
+    public static Collection<Object[]> params() {
+        return cartesianProduct(
+            F.asList(REPLICATED, PARTITIONED),
+            F.asList(ATOMIC, TRANSACTIONAL),
+            F.asList(false, true)
+        );
+    }
+
+    /** */
+    private final AtomicBoolean fail = new AtomicBoolean();
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        CacheConfiguration<?, ?> cacheCfg = new 
CacheConfiguration<>(DEFAULT_CACHE_NAME)
+            .setCacheMode(cacheMode)
+            .setAtomicityMode(cacheAtomicity);
+
+        return super.getConfiguration(igniteInstanceName)
+            .setFailureHandler((ignite, ctx) -> {
+                fail.set(true);
+                return true;
+            })
+            .setCacheConfiguration(cacheCfg);
+    }
+
+    /** */
+    @Test
+    public void testExceptionInLocalListener() throws Exception {
+        checkCQ(new ContinuousQuery<>().setLocalListener(evts -> {
+            throw new AssertionError();
+        }));
+    }
+
+    /** */
+    @Test
+    public void testExceptionInRemoteFilter() throws Exception {
+        checkCQ(new ContinuousQuery<>().setRemoteFilterFactory(() -> evts -> {
+            throw new AssertionError();
+        }));
+    }
+
+    /** */
+    @Test
+    public void testExceptionInTransformer() throws Exception {
+        checkCQ(new ContinuousQueryWithTransformer<>().setLocalListener(evts 
-> {})
+            .setRemoteTransformerFactory(() -> e -> {
+                throw new AssertionError();
+            }));
+    }
+
+    /** */
+    private void checkCQ(AbstractContinuousQuery<?, ?> cq) throws Exception {
+        fail.set(false);
+
+        if (locQry)
+            cq.setLocal(true);
+
+        IgniteEx ignite = startGrids(2);
+
+        IgniteCache<Object, Object> cache = ignite.cache(DEFAULT_CACHE_NAME);
+
+        cache.query(cq);
+
+        if (cacheAtomicity == TRANSACTIONAL) {
+            try (Transaction tx = ignite.transactions().txStart()) {
+                for (int i = 0; i < 100; i++)
+                    cache.put(i, 0);
+
+                tx.commit();
+            }
+        }
+        else {
+            for (int i = 0; i < 100; i++)
+                cache.put(i, 0);
+        }
+
+        assertFalse(fail.get());
+    }
+}
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite6.java
 
b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite6.java
index 714d316f122..81047163d75 100644
--- 
a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite6.java
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite6.java
@@ -34,6 +34,7 @@ import 
org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBin
 import 
org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationStoreEnabledTest;
 import 
org.apache.ignite.internal.processors.cache.query.continuous.CacheKeepBinaryIterationTest;
 import 
org.apache.ignite.internal.processors.cache.query.continuous.ContinuousQueryMarshallerTest;
+import 
org.apache.ignite.internal.processors.cache.query.continuous.ContinuousQueryUserCodeExceptionTest;
 import 
org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryMultiNodesFilteringTest;
 import 
org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionAtomicOneNodeTest;
 import 
org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedOnlySelfTest;
@@ -88,6 +89,7 @@ import org.junit.runners.Suite;
     CacheContinuousQueryEntriesExpireTest.class,
     DropTableAfterCteSqlQueryTest.class,
     LocalContinuousQueryWithNodeFailureTest.class,
+    ContinuousQueryUserCodeExceptionTest.class,
 })
 public class IgniteCacheQuerySelfTestSuite6 {
 }

Reply via email to