This is an automated email from the ASF dual-hosted git repository.
zstan 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 f488d707c96 IGNITE-22604 OOM caught internally in H2 does not call
failure handler (#11414)
f488d707c96 is described below
commit f488d707c967c86330a3cbd05b598721268298d2
Author: Evgeniy Stanilovskiy <[email protected]>
AuthorDate: Wed Jul 3 21:25:25 2024 +0300
IGNITE-22604 OOM caught internally in H2 does not call failure handler
(#11414)
---
.../processors/query/h2/IgniteH2Indexing.java | 6 ++
.../query/oom/IgniteQueryOOMTestSuite.java | 1 +
.../processors/query/oom/OOMLeadsTest.java | 96 ++++++++++++++++++++++
3 files changed, 103 insertions(+)
diff --git
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index f355dd70919..091a15c9230 100644
---
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -46,6 +46,8 @@ import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.EventType;
import org.apache.ignite.events.SqlQueryExecutionEvent;
+import org.apache.ignite.failure.FailureContext;
+import org.apache.ignite.failure.FailureType;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.GridTopic;
import org.apache.ignite.internal.IgniteInternalFuture;
@@ -692,6 +694,10 @@ public class IgniteH2Indexing implements GridQueryIndexing
{
if (e.getErrorCode() == ErrorCode.STATEMENT_WAS_CANCELED)
throw new QueryCancelledException();
+ if (e.getErrorCode() == ErrorCode.OUT_OF_MEMORY) {
+ ctx.failure().process(new
FailureContext(FailureType.CRITICAL_ERROR, e));
+ }
+
if (e.getCause() instanceof IgniteSQLException)
throw (IgniteSQLException)e.getCause();
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/oom/IgniteQueryOOMTestSuite.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/oom/IgniteQueryOOMTestSuite.java
index d57a607fe45..16843deeafb 100644
---
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/oom/IgniteQueryOOMTestSuite.java
+++
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/oom/IgniteQueryOOMTestSuite.java
@@ -28,6 +28,7 @@ import org.junit.runners.Suite;
//Query history.
QueryOOMWithoutQueryParallelismTest.class,
QueryOOMWithQueryParallelismTest.class,
+ OOMLeadsTest.class,
})
public class IgniteQueryOOMTestSuite {
}
diff --git
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/oom/OOMLeadsTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/oom/OOMLeadsTest.java
new file mode 100644
index 00000000000..b684f09aebd
--- /dev/null
+++
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/oom/OOMLeadsTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.query.oom;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.failure.StopNodeFailureHandler;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy;
+import org.junit.Test;
+
+import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
+
+/** Out of memory handling. */
+public class OOMLeadsTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected List<String> additionalRemoteJvmArgs() {
+ return Arrays.asList("-Xmx64m", "-Xms64m");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean isMultiJvm() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+
+ IgniteProcessProxy.killAll();
+
+ super.afterTest();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ cfg.setFailureHandler(new StopNodeFailureHandler());
+
+ return cfg;
+ }
+
+ /** Check correct handling for Out of memory. */
+ @Test
+ public void testOOMQueryHandling() throws Exception {
+ startGrids(2);
+
+ // stop local jvm node
+ stopGrid(0);
+
+ // check non oom sql processed correctly
+ runQuery("select x, space(100+x) as av from system_range(1, 1) group
by av");
+
+ // oom lead sql
+ assertThrows(null, () ->
+ runQuery("select x, space(10000000+x) as av from
system_range(1, 1000) group by av"),
+ IgniteException.class, "Out of memory");
+
+ IgniteEx grd = grid(1);
+
+ assertTrue(GridTestUtils.waitForCondition(() ->
!((IgniteProcessProxy)grd).getProcess().getProcess().isAlive(), 10_000));
+ }
+
+ /** */
+ private void runQuery(String sql) throws Exception {
+ try (Connection c = DriverManager.getConnection(
+ "jdbc:ignite:thin://127.0.0.1:10800..10850/")) {
+ try (Statement stmt = c.createStatement()) {
+ stmt.execute(sql);
+ }
+ }
+ }
+}