This is an automated email from the ASF dual-hosted git repository.
irakov 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 183034e IGNITE-11939
IgnitePdsTxHistoricalRebalancingTest.testTopologyChangesWithConstantLoad test
failure - Fixes #7400.
183034e is described below
commit 183034e2839d7de44ddafb38d36a2cd61b9cd68c
Author: Mirza Aliev <[email protected]>
AuthorDate: Wed Feb 12 20:50:02 2020 +0300
IGNITE-11939
IgnitePdsTxHistoricalRebalancingTest.testTopologyChangesWithConstantLoad test
failure - Fixes #7400.
Signed-off-by: Ivan Rakov <[email protected]>
---
.../GridCacheDatabaseSharedManager.java | 29 +++--
.../persistence/WalPreloadingConcurrentTest.java | 140 +++++++++++++++++++++
.../ignite/testsuites/IgnitePdsTestSuite2.java | 3 +
3 files changed, 163 insertions(+), 9 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
index 8000f5f..b11bb62 100755
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
@@ -60,6 +60,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.LongAdder;
+import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Consumer;
import java.util.function.Predicate;
@@ -429,6 +430,9 @@ public class GridCacheDatabaseSharedManager extends
IgniteCacheDatabaseSharedMan
/** Page list cache limits per data region. */
private final Map<String, AtomicLong> pageListCacheLimits = new
ConcurrentHashMap<>();
+ /** Lock for releasing history for preloading. */
+ private ReentrantLock releaseHistForPreloadingLock = new ReentrantLock();
+
/**
* @param ctx Kernal context.
*/
@@ -1868,18 +1872,25 @@ public class GridCacheDatabaseSharedManager extends
IgniteCacheDatabaseSharedMan
/** {@inheritDoc} */
@Override public void releaseHistoryForPreloading() {
- for (Map.Entry<T2<Integer, Integer>, T2<Long, WALPointer>> e :
reservedForPreloading.entrySet()) {
- try {
- cctx.wal().release(e.getValue().get2());
- }
- catch (IgniteCheckedException ex) {
- U.error(log, "Could not release WAL reservation", ex);
+ releaseHistForPreloadingLock.lock();
+
+ try {
+ for (Map.Entry<T2<Integer, Integer>, T2<Long, WALPointer>> e :
reservedForPreloading.entrySet()) {
+ try {
+ cctx.wal().release(e.getValue().get2());
+ }
+ catch (IgniteCheckedException ex) {
+ U.error(log, "Could not release WAL reservation", ex);
- throw new IgniteException(ex);
+ throw new IgniteException(ex);
+ }
}
- }
- reservedForPreloading.clear();
+ reservedForPreloading.clear();
+ }
+ finally {
+ releaseHistForPreloadingLock.unlock();
+ }
}
/**
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/WalPreloadingConcurrentTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/WalPreloadingConcurrentTest.java
new file mode 100644
index 0000000..1473325
--- /dev/null
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/WalPreloadingConcurrentTest.java
@@ -0,0 +1,140 @@
+/*
+ * 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;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+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.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+/**
+ * Tests if preloading operations for WAL work correctly for concurrent
invocations.
+ */
+public class WalPreloadingConcurrentTest extends GridCommonAbstractTest {
+ /** Threads number */
+ private static final int THREADS = 8;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override protected IgniteConfiguration getConfiguration(String gridName)
throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setConsistentId(gridName);
+
+ CacheConfiguration<Object, Object> ccfg = new
CacheConfiguration<>(DEFAULT_CACHE_NAME)
+ .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+ .setRebalanceMode(CacheRebalanceMode.ASYNC)
+ .setCacheMode(CacheMode.REPLICATED);
+
+ cfg.setCacheConfiguration(ccfg);
+
+ DataStorageConfiguration dbCfg = new DataStorageConfiguration()
+ .setWalMode(WALMode.LOG_ONLY)
+ .setDefaultDataRegionConfiguration(
+ new DataRegionConfiguration()
+ .setPersistenceEnabled(true)
+ );
+
+ cfg.setDataStorageConfiguration(dbCfg);
+
+ return cfg;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override protected void beforeTest() throws Exception {
+ stopAllGrids();
+ cleanPersistenceDir();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ cleanPersistenceDir();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @Test
+ public final void testConcurrentReserveReleaseHistoryForPreloading()
throws Exception {
+ IgniteEx ig = startGrid(0);
+
+ final int entryCnt = 3200;
+
+ ig.cluster().active(true);
+
+ IgniteInternalCache<Object, Object> cache =
ig.cachex(DEFAULT_CACHE_NAME);
+
+ for (int k = 0; k < entryCnt; k++)
+ cache.put(k, k);
+
+ forceCheckpoint();
+
+ GridCacheDatabaseSharedManager db =
(GridCacheDatabaseSharedManager)ig.context().cache().context().database();
+
+ AtomicBoolean stop = new AtomicBoolean(false);
+
+ //Millis
+ long duration = 5000L;
+
+ IgniteInternalFuture fut1 = multithreadedAsync(new Callable<Object>() {
+ @Override public Object call() {
+ int randomPart =
ThreadLocalRandom.current().nextInt(cache.configuration().getAffinity().partitions());
+
+ while (!stop.get())
+ db.reserveHistoryForPreloading(cache.context().groupId(),
randomPart, 0);
+
+ return null;
+ }
+ }, THREADS, "reserve-history-thread");
+
+ IgniteInternalFuture fut2 = multithreadedAsync(new Callable<Object>() {
+ @Override public Object call() {
+ while (!stop.get())
+ db.releaseHistoryForPreloading();
+
+ return null;
+ }
+ }, THREADS, "release-history-thread");
+
+ Thread.sleep(duration);
+
+ stop.set(true);
+
+ fut1.get();
+
+ fut2.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 16313f9..b5a314f 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
@@ -31,6 +31,7 @@ import
org.apache.ignite.internal.processors.cache.persistence.IgnitePersistentS
import
org.apache.ignite.internal.processors.cache.persistence.IgniteRebalanceScheduleResendPartitionsTest;
import
org.apache.ignite.internal.processors.cache.persistence.LocalWalModeChangeDuringRebalancingSelfTest;
import
org.apache.ignite.internal.processors.cache.persistence.LocalWalModeNoChangeDuringRebalanceOnNonNodeAssignTest;
+import
org.apache.ignite.internal.processors.cache.persistence.WalPreloadingConcurrentTest;
import
org.apache.ignite.internal.processors.cache.persistence.baseline.ClientAffinityAssignmentWithBaselineTest;
import
org.apache.ignite.internal.processors.cache.persistence.baseline.ClusterActivationEventTest;
import
org.apache.ignite.internal.processors.cache.persistence.baseline.ClusterActivationEventWithPersistenceTest;
@@ -256,5 +257,7 @@ public class IgnitePdsTestSuite2 {
GridTestUtils.addTestIfNeeded(suite,
IgnitePdsPartitionsStateRecoveryTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite,
IgnitePdsWithTtlDeactivateOnHighloadTest.class, ignoredTests);
+
+ GridTestUtils.addTestIfNeeded(suite,
WalPreloadingConcurrentTest.class, ignoredTests);
}
}