You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2021/03/18 07:06:01 UTC
[ignite] branch master updated: IGNITE-14322 Suppress redundant WAL
archive warning message in non-persistent mode - Fixes #8888.
This is an automated email from the ASF dual-hosted git repository.
sergeychugunov 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 dd67d3b IGNITE-14322 Suppress redundant WAL archive warning message in non-persistent mode - Fixes #8888.
dd67d3b is described below
commit dd67d3bd5815476e15d016484069965fd3e1c931
Author: Alexander Polovtcev <al...@gmail.com>
AuthorDate: Thu Mar 18 09:58:23 2021 +0300
IGNITE-14322 Suppress redundant WAL archive warning message in non-persistent mode - Fixes #8888.
Signed-off-by: Sergey Chugunov <se...@gmail.com>
---
.../IgniteCacheDatabaseSharedManager.java | 44 ++++---
.../db/wal/WalArchiveSizeConfigurationTest.java | 132 +++++++++++++++++++++
.../db/wal/WalDeletionArchiveAbstractTest.java | 25 ----
.../ignite/testsuites/IgnitePdsTestSuite2.java | 3 +
4 files changed, 161 insertions(+), 43 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
index 06df66a..6de343d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
@@ -101,8 +101,7 @@ import static java.util.Objects.nonNull;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_REUSE_MEMORY_ON_DEACTIVATE;
import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_DATA_REG_DEFAULT_NAME;
import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_PAGE_SIZE;
-import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_ARCHIVE_MAX_SIZE;
-import static org.apache.ignite.configuration.DataStorageConfiguration.DFLT_WAL_HISTORY_SIZE;
+import static org.apache.ignite.configuration.DataStorageConfiguration.UNLIMITED_WAL_ARCHIVE;
import static org.apache.ignite.internal.processors.cache.mvcc.txlog.TxLog.TX_LOG_CACHE_NAME;
import static org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.METASTORE_DATA_REGION_NAME;
import static org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.VOLATILE_DATA_REGION_NAME;
@@ -618,28 +617,37 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
}
/**
- * Check wal archive size configuration for correctness.
+ * Check WAL archive size configuration for correctness.
*
* @param memCfg durable memory configuration for an Apache Ignite node.
+ * @throws IgniteCheckedException if maximum WAL archive size is configured incorrectly
*/
private void checkWalArchiveSizeConfiguration(DataStorageConfiguration memCfg) throws IgniteCheckedException {
- if (memCfg.getWalHistorySize() == DFLT_WAL_HISTORY_SIZE || memCfg.getWalHistorySize() == Integer.MAX_VALUE)
- LT.warn(log, "DataRegionConfiguration.maxWalArchiveSize instead DataRegionConfiguration.walHistorySize " +
- "would be used for removing old archive wal files");
- else if (memCfg.getMaxWalArchiveSize() == DFLT_WAL_ARCHIVE_MAX_SIZE)
- LT.warn(log, "walHistorySize was deprecated and does not have any effect anymore. " +
- "maxWalArchiveSize should be used instead");
- else
- throw new IgniteCheckedException("Should be used only one of wal history size or max wal archive size." +
- "(use DataRegionConfiguration.maxWalArchiveSize because DataRegionConfiguration.walHistorySize was deprecated)"
- );
+ long maxWalArchiveSize = memCfg.getMaxWalArchiveSize();
- if (memCfg.getMaxWalArchiveSize() != DataStorageConfiguration.UNLIMITED_WAL_ARCHIVE
- && memCfg.getMaxWalArchiveSize() < memCfg.getWalSegmentSize())
- throw new IgniteCheckedException(
- "DataRegionConfiguration.maxWalArchiveSize should be greater than DataRegionConfiguration.walSegmentSize " +
- "or must be equal to " + DataStorageConfiguration.UNLIMITED_WAL_ARCHIVE + "."
+ if (!CU.isPersistenceEnabled(memCfg)) {
+ if (maxWalArchiveSize != DataStorageConfiguration.DFLT_WAL_ARCHIVE_MAX_SIZE) {
+ LT.info(log, "Maximum WAL archive size has been configured but this node has been launched in " +
+ "non-persistent mode, so this parameter will be ignored");
+ }
+ return;
+ }
+
+ if (memCfg.isWalHistorySizeParameterUsed())
+ LT.warn(log,
+ "DataRegionConfiguration.walHistorySize property is deprecated and is no longer supported. " +
+ "It will be ignored and DataRegionConfiguration.maxWalArchiveSize property will be used " +
+ "instead to control removal of archived WAL files"
);
+
+ if (maxWalArchiveSize != UNLIMITED_WAL_ARCHIVE && maxWalArchiveSize < memCfg.getWalSegmentSize())
+ throw new IgniteCheckedException(String.format(
+ "DataRegionConfiguration.maxWalArchiveSize must be no less than " +
+ "DataRegionConfiguration.walSegmentSize or equal to %d (unlimited size), current settings:" + System.lineSeparator() +
+ "DataRegionConfiguration.maxWalArchiveSize: %d bytes" + System.lineSeparator() +
+ "DataRegionConfiguration.walSegmentSize: %d bytes",
+ UNLIMITED_WAL_ARCHIVE, memCfg.getMaxWalArchiveSize(), memCfg.getWalSegmentSize()
+ ));
}
/**
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalArchiveSizeConfigurationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalArchiveSizeConfigurationTest.java
new file mode 100644
index 0000000..824fe9a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalArchiveSizeConfigurationTest.java
@@ -0,0 +1,132 @@
+/*
+ * 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.persistence.db.wal;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test suite for checking WAL archive size configuration validation.
+ */
+public class WalArchiveSizeConfigurationTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ cleanPersistenceDir();
+ }
+
+ /**
+ * Checks that no warning messages regarding WAL configuration are logged when a node is started in
+ * non-persistent mode, even if they are not correct.
+ */
+ @Test
+ public void testNonPersistentConfiguration() throws Exception {
+ String logMsg = getPersistentWalLogWarning(false);
+ assertTrue(
+ "Invalid configuration warning was printed during non-persistent startup: " + logMsg,
+ logMsg.isEmpty()
+ );
+ }
+
+ /**
+ * Checks that a warning is logged if legacy WAL configuration parameters are used.
+ */
+ @Test
+ public void testPersistentConfiguration() throws Exception {
+ String logMsg = getPersistentWalLogWarning(true);
+ assertFalse(
+ "Configuration warning was not printed during persistent startup",
+ logMsg.isEmpty()
+ );
+ }
+
+ /**
+ * Checks that an exception is thrown if WAL segment size is larger than max WAL archive size.
+ */
+ @Test
+ public void testIncorrectMaxArchiveSizeConfiguration() throws Exception {
+ DataStorageConfiguration dataStorageConfiguration = new DataStorageConfiguration()
+ .setWalSegmentSize((int) U.MB)
+ .setMaxWalArchiveSize(10)
+ .setDefaultDataRegionConfiguration(
+ new DataRegionConfiguration().setPersistenceEnabled(true)
+ );
+
+ try {
+ startGrid(0, (IgniteConfiguration cfg) -> cfg.setDataStorageConfiguration(dataStorageConfiguration));
+ } catch (IgniteCheckedException e) {
+ assertThat(e.getCause().getMessage(), containsString("maxWalArchiveSize must be no less than"));
+ }
+ }
+
+ /**
+ * Checks that no exceptions are thrown for a special case of unlimited WAL archive size value.
+ */
+ @Test
+ public void testUnlimitedMaxArchiveSizeConfiguration() throws Exception {
+ DataStorageConfiguration dataStorageConfiguration = new DataStorageConfiguration()
+ .setWalSegmentSize((int) U.MB)
+ .setMaxWalArchiveSize(DataStorageConfiguration.UNLIMITED_WAL_ARCHIVE)
+ .setDefaultDataRegionConfiguration(
+ new DataRegionConfiguration().setPersistenceEnabled(true)
+ );
+
+ startGrid(0, (IgniteConfiguration cfg) -> cfg.setDataStorageConfiguration(dataStorageConfiguration));
+ }
+
+ /**
+ * Starts up a node in persistent or non-persistent mode and retrieves log messages.
+ */
+ private String getPersistentWalLogWarning(boolean isPersistenceEnabled) throws Exception {
+ List<String> msgReceived = Collections.synchronizedList(new ArrayList<>());
+ ListeningTestLogger listeningLog = new ListeningTestLogger();
+ listeningLog.registerListener(logMsg -> {
+ if (logMsg.contains("walHistorySize property is deprecated"))
+ msgReceived.add(logMsg);
+ });
+
+ DataStorageConfiguration dataStorageConfiguration = new DataStorageConfiguration()
+ .setWalHistorySize(123)
+ .setDefaultDataRegionConfiguration(
+ new DataRegionConfiguration().setPersistenceEnabled(isPersistenceEnabled)
+ );
+
+ startGrid(0, (IgniteConfiguration cfg) ->
+ cfg
+ .setDataStorageConfiguration(dataStorageConfiguration)
+ .setGridLogger(listeningLog)
+ );
+
+ assertTrue("Received more messages than expected: " + msgReceived, msgReceived.size() <= 1);
+ return msgReceived.isEmpty() ? "" : msgReceived.get(0);
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalDeletionArchiveAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalDeletionArchiveAbstractTest.java
index 479021c..c1ef5a6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalDeletionArchiveAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/WalDeletionArchiveAbstractTest.java
@@ -25,7 +25,6 @@ import java.util.function.Consumer;
import java.util.stream.Stream;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -110,30 +109,6 @@ public abstract class WalDeletionArchiveAbstractTest extends GridCommonAbstractT
protected abstract WALMode walMode();
/**
- * History size parameters consistency check. Should be set just one of wal history size or max wal archive size.
- */
- @Test
- public void testGridDoesNotStart_BecauseBothWalHistorySizeAndMaxWalArchiveSizeUsed() throws Exception {
- //given: wal history size and max wal archive size are both set.
- IgniteConfiguration configuration = getConfiguration(getTestIgniteInstanceName());
-
- DataStorageConfiguration dbCfg = new DataStorageConfiguration();
- dbCfg.setWalHistorySize(12);
- dbCfg.setMaxWalArchiveSize(9);
- configuration.setDataStorageConfiguration(dbCfg);
-
- try {
- //when: start grid.
- startGrid(getTestIgniteInstanceName(), configuration);
- fail("Should be fail because both wal history size and max wal archive size was used");
- }
- catch (IgniteException e) {
- //then: exception is occurrence because should be set just one parameters.
- assertTrue(findSourceMessage(e).startsWith("Should be used only one of wal history size or max wal archive size"));
- }
- }
-
- /**
* find first cause's message
*/
private String findSourceMessage(Throwable ex) {
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
index 9a2feb5..d9e6d83 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
@@ -77,6 +77,7 @@ import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalR
import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalRecoverySeveralRestartsTest;
import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalReplayingAfterRestartTest;
import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalSerializerVersionTest;
+import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalArchiveSizeConfigurationTest;
import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalCompactionNoArchiverTest;
import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalCompactionSwitchOnTest;
import org.apache.ignite.internal.processors.cache.persistence.db.wal.WalCompactionTest;
@@ -144,6 +145,8 @@ public class IgnitePdsTestSuite2 {
// Maintenance tests
GridTestUtils.addTestIfNeeded(suite, MaintenanceRegistrySimpleTest.class, ignoredTests);
+ GridTestUtils.addTestIfNeeded(suite, WalArchiveSizeConfigurationTest.class, ignoredTests);
+
return suite;
}