-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-27473: WALMode consistency check and tests #12614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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<ClusterNode> 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<ClusterNode> 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. " + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest making the error message consistent with existing ones, for example: |
||
| " Local node(locNodeAddrs=" + U.addressesAsString(locNode) + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Required indent is 4-space characters, currently it is 8. |
||
| ", 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()) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| /* | ||
| * 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 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A test class needs to be added to the suite. |
||
| /** */ | ||
| private final ListeningTestLogger testLog = new ListeningTestLogger(log); | ||
|
|
||
| /** */ | ||
| private WALMode walMode; | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { | ||
| IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName) | ||
| .setGridLogger(testLog); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can be placed in one line. |
||
|
|
||
| DataStorageConfiguration dsCfg = new DataStorageConfiguration(); | ||
| dsCfg.setWalMode(walMode).getDefaultDataRegionConfiguration().setPersistenceEnabled(true); | ||
|
|
||
| cfg.setDataStorageConfiguration(dsCfg); | ||
|
|
||
| return cfg; | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override protected void beforeTest() throws Exception { | ||
| super.beforeTest(); | ||
|
|
||
| walMode = null; | ||
| } | ||
|
|
||
| /** {@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; | ||
|
|
||
| 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; | ||
|
|
||
| IgniteEx ignite0 = startGrid(0); | ||
|
|
||
| walMode = WALMode.FSYNC; | ||
|
|
||
| LogListener walModeErrorLsnr = LogListener.matches("WAL mode validation failed") | ||
| .andMatches("LOG_ONLY") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Required indent is 4-space characters. |
||
| .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()); | ||
| } | ||
|
|
||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove empty line. |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove curly braces for one line statement.