You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ni...@apache.org on 2022/02/11 18:54:16 UTC
[ignite] branch master updated: IGNITE-16523 Rollover by timeout fixed (#9815)
This is an automated email from the ASF dual-hosted git repository.
nizhikov 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 6ca3e2d IGNITE-16523 Rollover by timeout fixed (#9815)
6ca3e2d is described below
commit 6ca3e2d3ab1ee6bef8588d202fd1e38df3a00244
Author: Nikolay <ni...@apache.org>
AuthorDate: Fri Feb 11 21:53:25 2022 +0300
IGNITE-16523 Rollover by timeout fixed (#9815)
---
.../persistence/wal/FileWriteAheadLogManager.java | 15 ++--
.../cdc/RestartWithWalForceArchiveTimeoutTest.java | 95 ++++++++++++++++++++++
.../ignite/testsuites/IgnitePdsTestSuite2.java | 2 +
3 files changed, 107 insertions(+), 5 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
index 655dc47..f72bf3d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
@@ -796,6 +796,9 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
assert timeoutRolloverMux != null;
synchronized (timeoutRolloverMux) {
+ if (timeoutRollover != null)
+ return;
+
long nextEndTime = walForceArchiveTimeout > 0
? nextTimeout(lastRolloverMs.get(), walForceArchiveTimeout)
: nextTimeout(lastRecordLoggedMs.get(), walAutoArchiveAfterInactivity);
@@ -806,7 +809,7 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
/** */
private long nextTimeout(long lastEvt, long timeout) {
- return lastEvt <= 0 ? U.currentTimeMillis() : lastEvt + timeout;
+ return (lastEvt <= 0 ? U.currentTimeMillis() : lastEvt) + timeout;
}
/** {@inheritDoc} */
@@ -3515,11 +3518,11 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
assert timeoutRolloverMux != null;
synchronized (timeoutRolloverMux) {
+ timeoutRollover = null;
+
if (!cancel) {
- if (log.isDebugEnabled()) {
- log.debug("Checking if WAL rollover required (" +
- new Time(U.currentTimeMillis()).toString() + ")");
- }
+ if (log.isDebugEnabled())
+ log.debug("Checking if WAL rollover required (" + new Time(U.currentTimeMillis()) + ")");
checkWalRolloverRequired();
@@ -3558,6 +3561,8 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
timeoutRollover.cancel();
cctx.time().removeTimeoutObject(timeoutRollover);
+
+ this.timeoutRollover = null;
}
}
}
diff --git a/modules/core/src/test/java/org/apache/ignite/cdc/RestartWithWalForceArchiveTimeoutTest.java b/modules/core/src/test/java/org/apache/ignite/cdc/RestartWithWalForceArchiveTimeoutTest.java
new file mode 100644
index 0000000..d28abb3
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cdc/RestartWithWalForceArchiveTimeoutTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.cdc;
+
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.function.Supplier;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+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.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.apache.ignite.cdc.CdcSelfTest.addData;
+import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+
+/** */
+@RunWith(Parameterized.class)
+public class RestartWithWalForceArchiveTimeoutTest extends GridCommonAbstractTest {
+ /** */
+ @Parameterized.Parameter
+ public WALMode walMode;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ cfg.setConsistentId(igniteInstanceName);
+
+ cfg.setDataStorageConfiguration(new DataStorageConfiguration()
+ .setWalMode(walMode)
+ .setWalForceArchiveTimeout(60 * 60 * 1000) // 1 hour to make sure auto archive will not work.
+ .setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));
+
+ return cfg;
+ }
+
+ /** */
+ @Parameterized.Parameters(name = "walMode={0}")
+ public static Collection<?> parameters() {
+ return EnumSet.of(WALMode.FSYNC, WALMode.LOG_ONLY, WALMode.BACKGROUND);
+ }
+
+ /** */
+ @Test
+ public void testRestart() throws Exception {
+ stopAllGrids(true);
+
+ cleanPersistenceDir();
+
+ Supplier<IgniteEx> restart = () -> {
+ stopAllGrids(true);
+
+ try {
+ IgniteEx ign = startGrid(getConfiguration("ignite-0"));
+
+ ign.cluster().state(ACTIVE);
+
+ return ign;
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ };
+
+ IgniteEx ign = restart.get();
+
+ IgniteCache<Integer, AbstractCdcTest.User> cache = ign.getOrCreateCache(DEFAULT_CACHE_NAME);
+
+ addData(cache, 0, 100);
+
+ for (int i = 0; i < 5; i++)
+ restart.get();
+ }
+}
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 445002b..2035c98 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
@@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.List;
import org.apache.ignite.cdc.CdcCacheVersionTest;
import org.apache.ignite.cdc.CdcSelfTest;
+import org.apache.ignite.cdc.RestartWithWalForceArchiveTimeoutTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.HistoricalRebalanceHeuristicsTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.HistoricalRebalanceTwoPartsInDifferentCheckpointsTest;
import org.apache.ignite.internal.processors.cache.persistence.IgniteDataStorageMetricsSelfTest;
@@ -217,6 +218,7 @@ public class IgnitePdsTestSuite2 {
// CDC tests.
GridTestUtils.addTestIfNeeded(suite, CdcSelfTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, CdcCacheVersionTest.class, ignoredTests);
+ GridTestUtils.addTestIfNeeded(suite, RestartWithWalForceArchiveTimeoutTest.class, ignoredTests);
// new style folders with generated consistent ID test
GridTestUtils.addTestIfNeeded(suite, IgniteUidAsConsistentIdMigrationTest.class, ignoredTests);