From 8958b48263c1e7b0546b9adfadcceaf41c3741ae Mon Sep 17 00:00:00 2001 From: Maxim Pankovich Date: Mon, 29 Dec 2025 15:38:19 +0300 Subject: [PATCH 1/3] walmode consistency check and tests --- .../ignite/internal/IgniteNodeAttributes.java | 3 + .../discovery/GridDiscoveryManager.java | 25 ++++ ...iscoveryManagerWalModeConsistencyTest.java | 123 ++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerWalModeConsistencyTest.java diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java index 7e79a695caea9..6fe432f81a3ae 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java @@ -199,6 +199,9 @@ public final class IgniteNodeAttributes { /** Data center ID. */ public static final String ATTR_DATA_CENTER_ID = ATTR_PREFIX + ".datacenter.id"; + /** WAL mode configuration. */ + public static final String ATTR_WAL_MODE = ATTR_PREFIX + ".wal.mode"; + /** * Enforces singleton. */ diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java index 7334cfc16c9a9..3dc156368fbef 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java @@ -58,6 +58,7 @@ import org.apache.ignite.configuration.DataStorageConfiguration; import org.apache.ignite.configuration.DefaultCommunicationFailureResolver; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.WALMode; import org.apache.ignite.events.DiscoveryEvent; import org.apache.ignite.events.Event; import org.apache.ignite.events.EventType; @@ -176,6 +177,7 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SECURITY_COMPATIBILITY_MODE; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SHUTDOWN_POLICY; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_USER_NAME; +import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_WAL_MODE; import static org.apache.ignite.internal.IgniteVersionUtils.VER; import static org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT; import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName; @@ -484,6 +486,12 @@ private void updateClientNodes(UUID leftNodeId) { ctx.addNodeAttribute(ATTR_OFFHEAP_SIZE, requiredOffheap()); ctx.addNodeAttribute(ATTR_DATA_REGIONS_OFFHEAP_SIZE, configuredOffheap()); + DataStorageConfiguration dsCfg = ctx.config().getDataStorageConfiguration(); + + if (dsCfg != null) { + ctx.addNodeAttribute(ATTR_WAL_MODE, dsCfg.getWalMode()); + } + DiscoverySpi spi = getSpi(); discoOrdered = discoOrdered(); @@ -1279,6 +1287,8 @@ private void checkAttributes(Iterable nodes) throws IgniteCheckedEx Boolean locSecurityCompatibilityEnabled = locNode.attribute(ATTR_SECURITY_COMPATIBILITY_MODE); + WALMode locWalMode = locNode.attribute(ATTR_WAL_MODE); + for (ClusterNode n : nodes) { int rmtJvmMajVer = nodeJavaMajorVersion(n); @@ -1383,6 +1393,21 @@ private void checkAttributes(Iterable nodes) throws IgniteCheckedEx ", locNodeId=" + locNode.id() + ", rmtNode=" + U.toShortString(n) + "]"); } } + + WALMode rmtWalMode = n.attribute(ATTR_WAL_MODE); + + if (locWalMode != rmtWalMode) { + throw new IgniteCheckedException("WAL mode validation failed. " + + " Local node(locNodeAddrs=" + U.addressesAsString(locNode) + + ", id=" + locNode.id() + + ", consistentId=" + locNode.consistentId() + + ", WALMode=" + locWalMode + + "), Remote node(rmtNodeAddrs=" + U.addressesAsString(n) + + ", id=" + n.id() + + ", consistentId=" + n.consistentId() + + ", WALMode=" + rmtWalMode + + "). All nodes in the cluster must have the same WALMode configuration."); + } } if (log.isDebugEnabled()) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerWalModeConsistencyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerWalModeConsistencyTest.java new file mode 100644 index 0000000000000..a11b036a8f328 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerWalModeConsistencyTest.java @@ -0,0 +1,123 @@ +/* + * 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.managers.discovery; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.IgniteEx; +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; + +/** + * Tests for WAL mode consistency validation when nodes join cluster. + */ +public class GridDiscoveryManagerWalModeConsistencyTest extends GridCommonAbstractTest { + /** */ + private final ListeningTestLogger testLog = new ListeningTestLogger(log); + + /** */ + private WALMode walMode; + + /** */ + private boolean persistenceEnabled; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName) + .setGridLogger(testLog); + + DataStorageConfiguration dsCfg = new DataStorageConfiguration(); + dsCfg.setWalMode(walMode); + + if (persistenceEnabled) { + dsCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(true); + } + + cfg.setDataStorageConfiguration(dsCfg); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + walMode = null; + persistenceEnabled = false; + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + super.afterTest(); + } + + /** + * Tests that nodes with same WAL mode can join cluster successfully. + * + * @throws Exception If failed. + */ + @Test + public void testSameWalModeJoinsSuccessfully() throws Exception { + walMode = WALMode.LOG_ONLY; + persistenceEnabled = true; + + IgniteEx ignite0 = startGrid(0); + + IgniteEx ignite1 = startGrid(1); + + assertEquals(2, ignite0.cluster().nodes().size()); + assertEquals(2, ignite1.cluster().nodes().size()); + } + + /** + * Tests that nodes with different WAL modes cannot join cluster. + * + * @throws Exception If failed. + */ + @Test + public void testDifferentWalModesCannotJoin() throws Exception { + walMode = WALMode.LOG_ONLY; + persistenceEnabled = true; + + IgniteEx ignite0 = startGrid(0); + + walMode = WALMode.FSYNC; + + LogListener walModeErrorLsnr = LogListener.matches("WAL mode validation failed") + .andMatches("LOG_ONLY") + .andMatches("FSYNC") + .andMatches("All nodes in the cluster must have the same WALMode configuration") + .build(); + testLog.registerListener(walModeErrorLsnr); + + GridTestUtils.assertThrowsWithCause(() -> startGrid(1), IgniteCheckedException.class); + + assertTrue(walModeErrorLsnr.check()); + assertEquals(1, ignite0.cluster().nodes().size()); + } + + +} From c35a990ae354210935a00c7cdfc6b8212bec29d5 Mon Sep 17 00:00:00 2001 From: Maxim Pankovich Date: Mon, 29 Dec 2025 15:51:28 +0300 Subject: [PATCH 2/3] remove persistence --- .../GridDiscoveryManagerWalModeConsistencyTest.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerWalModeConsistencyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerWalModeConsistencyTest.java index a11b036a8f328..c44d272d22571 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerWalModeConsistencyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerWalModeConsistencyTest.java @@ -39,20 +39,13 @@ public class GridDiscoveryManagerWalModeConsistencyTest extends GridCommonAbstra /** */ private WALMode walMode; - /** */ - private boolean persistenceEnabled; - /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName) .setGridLogger(testLog); DataStorageConfiguration dsCfg = new DataStorageConfiguration(); - dsCfg.setWalMode(walMode); - - if (persistenceEnabled) { - dsCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(true); - } + dsCfg.setWalMode(walMode).getDefaultDataRegionConfiguration().setPersistenceEnabled(true); cfg.setDataStorageConfiguration(dsCfg); @@ -64,7 +57,6 @@ public class GridDiscoveryManagerWalModeConsistencyTest extends GridCommonAbstra super.beforeTest(); walMode = null; - persistenceEnabled = false; } /** {@inheritDoc} */ @@ -82,7 +74,6 @@ public class GridDiscoveryManagerWalModeConsistencyTest extends GridCommonAbstra @Test public void testSameWalModeJoinsSuccessfully() throws Exception { walMode = WALMode.LOG_ONLY; - persistenceEnabled = true; IgniteEx ignite0 = startGrid(0); @@ -100,7 +91,6 @@ public void testSameWalModeJoinsSuccessfully() throws Exception { @Test public void testDifferentWalModesCannotJoin() throws Exception { walMode = WALMode.LOG_ONLY; - persistenceEnabled = true; IgniteEx ignite0 = startGrid(0); From 259d609e9163a044f63ac52251e14ef1bb88b9c4 Mon Sep 17 00:00:00 2001 From: Maxim Pankovich Date: Mon, 19 Jan 2026 13:24:37 +0300 Subject: [PATCH 3/3] review fixes 1 --- .../discovery/GridDiscoveryManager.java | 17 +++++------------ ...DiscoveryManagerWalModeConsistencyTest.java | 18 ++++++------------ .../testsuites/IgniteKernalSelfTestSuite.java | 2 ++ 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java index 3dc156368fbef..c5d3c43b9a7b0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java @@ -488,9 +488,8 @@ private void updateClientNodes(UUID leftNodeId) { DataStorageConfiguration dsCfg = ctx.config().getDataStorageConfiguration(); - if (dsCfg != null) { + if (dsCfg != null) ctx.addNodeAttribute(ATTR_WAL_MODE, dsCfg.getWalMode()); - } DiscoverySpi spi = getSpi(); @@ -1397,16 +1396,10 @@ private void checkAttributes(Iterable nodes) throws IgniteCheckedEx WALMode rmtWalMode = n.attribute(ATTR_WAL_MODE); if (locWalMode != rmtWalMode) { - throw new IgniteCheckedException("WAL mode validation failed. " + - " Local node(locNodeAddrs=" + U.addressesAsString(locNode) + - ", id=" + locNode.id() + - ", consistentId=" + locNode.consistentId() + - ", WALMode=" + locWalMode + - "), Remote node(rmtNodeAddrs=" + U.addressesAsString(n) + - ", id=" + n.id() + - ", consistentId=" + n.consistentId() + - ", WALMode=" + rmtWalMode + - "). All nodes in the cluster must have the same WALMode configuration."); + throw new IgniteCheckedException("Remote node has WAL mode different from local " + + "[locId8=" + U.id8(locNode.id()) + ", locWalMode=" + locWalMode + + ", rmtId8=" + U.id8(n.id()) + ", rmtWalMode=" + rmtWalMode + + ", rmtAddrs=" + U.addressesAsString(n) + ", rmtNode=" + U.toShortString(n) + "]"); } } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerWalModeConsistencyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerWalModeConsistencyTest.java index c44d272d22571..4d2210d6d2066 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerWalModeConsistencyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerWalModeConsistencyTest.java @@ -29,9 +29,7 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.junit.Test; -/** - * Tests for WAL mode consistency validation when nodes join cluster. - */ +/** Tests for WAL mode consistency validation when nodes join cluster. */ public class GridDiscoveryManagerWalModeConsistencyTest extends GridCommonAbstractTest { /** */ private final ListeningTestLogger testLog = new ListeningTestLogger(log); @@ -41,8 +39,7 @@ public class GridDiscoveryManagerWalModeConsistencyTest extends GridCommonAbstra /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName) - .setGridLogger(testLog); + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName).setGridLogger(testLog); DataStorageConfiguration dsCfg = new DataStorageConfiguration(); dsCfg.setWalMode(walMode).getDefaultDataRegionConfiguration().setPersistenceEnabled(true); @@ -96,11 +93,10 @@ public void testDifferentWalModesCannotJoin() throws Exception { walMode = WALMode.FSYNC; - LogListener walModeErrorLsnr = LogListener.matches("WAL mode validation failed") - .andMatches("LOG_ONLY") - .andMatches("FSYNC") - .andMatches("All nodes in the cluster must have the same WALMode configuration") - .build(); + LogListener walModeErrorLsnr = LogListener.matches("Remote node has WAL mode different from local") + .andMatches("LOG_ONLY") + .andMatches("FSYNC") + .build(); testLog.registerListener(walModeErrorLsnr); GridTestUtils.assertThrowsWithCause(() -> startGrid(1), IgniteCheckedException.class); @@ -108,6 +104,4 @@ public void testDifferentWalModesCannotJoin() throws Exception { assertTrue(walModeErrorLsnr.check()); assertEquals(1, ignite0.cluster().nodes().size()); } - - } diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java index 90675f4aa0a02..dd6dd06042cb6 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java @@ -47,6 +47,7 @@ import org.apache.ignite.internal.managers.deployment.GridDeploymentManagerStopSelfTest; import org.apache.ignite.internal.managers.discovery.GridDiscoveryManagerAliveCacheSelfTest; import org.apache.ignite.internal.managers.discovery.GridDiscoveryManagerAttributesSelfTest; +import org.apache.ignite.internal.managers.discovery.GridDiscoveryManagerWalModeConsistencyTest; import org.apache.ignite.internal.managers.discovery.IgniteTopologyPrintFormatSelfTest; import org.apache.ignite.internal.managers.events.GridEventStorageManagerInternalEventsSelfTest; import org.apache.ignite.internal.managers.events.GridEventStorageManagerSelfTest; @@ -91,6 +92,7 @@ GridManagerStopSelfTest.class, GridDiscoveryManagerAttributesSelfTest.class, GridDiscoveryManagerAliveCacheSelfTest.class, + GridDiscoveryManagerWalModeConsistencyTest.class, GridDiscoveryEventSelfTest.class, GridPortProcessorSelfTest.class, GridHomePathSelfTest.class,