This is an automated email from the ASF dual-hosted git repository.
alexpl 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 ed1e06f IGNITE-12855 Fixed failure with concurrent get operation and
entry expiration - Fixes #7609.
ed1e06f is described below
commit ed1e06fbc54a9f2d8055e59d805fdd618630e876
Author: Aleksey Plekhanov <[email protected]>
AuthorDate: Tue Apr 28 12:38:52 2020 +0300
IGNITE-12855 Fixed failure with concurrent get operation and entry
expiration - Fixes #7609.
Signed-off-by: Aleksey Plekhanov <[email protected]>
---
.../processors/cache/GridCacheAdapter.java | 5 +
.../cache/distributed/dht/GridDhtCacheAdapter.java | 2 +-
.../distributed/dht/atomic/GridDhtAtomicCache.java | 5 +
.../dht/colocated/GridDhtColocatedCache.java | 5 +
.../cache/local/atomic/GridLocalAtomicCache.java | 225 +++++++++++----------
.../cache/persistence/GridCacheOffheapManager.java | 20 +-
.../cache/transactions/IgniteTxManager.java | 16 +-
.../IgnitePdsWithTtlDeactivateOnHighloadTest.java | 101 +++++----
8 files changed, 221 insertions(+), 158 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index d0350ca..bb384d0 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -2061,6 +2061,8 @@ public abstract class GridCacheAdapter<K, V> implements
IgniteInternalCache<K, V
final AffinityTopologyVersion topVer = tx == null ?
ctx.affinity().affinityTopologyVersion() :
tx.topologyVersion();
+ ctx.shared().database().checkpointReadLock();
+
try {
int keysSize = keys.size();
@@ -2383,6 +2385,9 @@ public abstract class GridCacheAdapter<K, V> implements
IgniteInternalCache<K, V
catch (IgniteCheckedException e) {
return new GridFinishedFuture<>(e);
}
+ finally {
+ ctx.shared().database().checkpointReadUnlock();
+ }
}
else {
return asyncOp(tx, new AsyncOp<Map<K1, V1>>(keys) {
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index c0bdfeb..e76b6c6 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -1002,7 +1002,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends
GridDistributedCacheAdap
* @param expiryPlc Expiry policy.
*/
public void sendTtlUpdateRequest(@Nullable final IgniteCacheExpiryPolicy
expiryPlc) {
- if (expiryPlc != null && expiryPlc.entries() != null) {
+ if (expiryPlc != null && !F.isEmpty(expiryPlc.entries())) {
ctx.closures().runLocalSafe(new Runnable() {
@SuppressWarnings({"ForLoopReplaceableByForEach"})
@Override public void run() {
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 6233f57..8c5d84c9 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -1522,6 +1522,8 @@ public class GridDhtAtomicCache<K, V> extends
GridDhtCacheAdapter<K, V> {
// Optimisation: try to resolve value locally and escape 'get future'
creation.
if (!forcePrimary && ctx.affinityNode()) {
+ ctx.shared().database().checkpointReadLock();
+
try {
Map<K, V> locVals = U.newHashMap(keys.size());
@@ -1670,6 +1672,9 @@ public class GridDhtAtomicCache<K, V> extends
GridDhtCacheAdapter<K, V> {
catch (IgniteCheckedException e) {
return new GridFinishedFuture<>(e);
}
+ finally {
+ ctx.shared().database().checkpointReadUnlock();
+ }
}
if (expiry != null)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 6dc4c5a..217b968 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -528,6 +528,8 @@ public class GridDhtColocatedCache<K, V> extends
GridDhtTransactionalCacheAdapte
// Optimization: try to resolve value locally and escape 'get future'
creation.
if (!forcePrimary && ctx.affinityNode()) {
+ ctx.shared().database().checkpointReadLock();
+
try {
Map<K, V> locVals = null;
@@ -686,6 +688,9 @@ public class GridDhtColocatedCache<K, V> extends
GridDhtTransactionalCacheAdapte
catch (IgniteCheckedException e) {
return new GridFinishedFuture<>(e);
}
+ finally {
+ ctx.shared().database().checkpointReadUnlock();
+ }
}
if (expiryPlc != null)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index fb40d0c..d6cf4ac 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -395,139 +395,146 @@ public class GridLocalAtomicCache<K, V> extends
GridLocalCache<K, V> {
boolean readNoEntry = ctx.readNoEntry(expiry, false);
final boolean evt = !skipVals;
- for (K key : keys) {
- if (key == null)
- throw new NullPointerException("Null key.");
-
- KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
+ ctx.shared().database().checkpointReadLock();
- boolean skipEntry = readNoEntry;
+ try {
+ for (K key : keys) {
+ if (key == null)
+ throw new NullPointerException("Null key.");
- if (readNoEntry) {
- CacheDataRow row = ctx.offheap().read(ctx, cacheKey);
+ KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
- if (row != null) {
- long expireTime = row.expireTime();
+ boolean skipEntry = readNoEntry;
- if (expireTime == 0 || expireTime > U.currentTimeMillis())
{
- ctx.addResult(vals,
- cacheKey,
- row.value(),
- skipVals,
- false,
- deserializeBinary,
- true,
- null,
- row.version(),
- 0,
- 0,
- needVer);
+ if (readNoEntry) {
+ CacheDataRow row = ctx.offheap().read(ctx, cacheKey);
- if (ctx.statisticsEnabled() && !skipVals)
- metrics0().onRead(true);
+ if (row != null) {
+ long expireTime = row.expireTime();
- if (evt) {
- ctx.events().readEvent(cacheKey,
- null,
- null,
+ if (expireTime == 0 || expireTime >
U.currentTimeMillis()) {
+ ctx.addResult(vals,
+ cacheKey,
row.value(),
- subjId,
- taskName,
- !deserializeBinary);
+ skipVals,
+ false,
+ deserializeBinary,
+ true,
+ null,
+ row.version(),
+ 0,
+ 0,
+ needVer);
+
+ if (ctx.statisticsEnabled() && !skipVals)
+ metrics0().onRead(true);
+
+ if (evt) {
+ ctx.events().readEvent(cacheKey,
+ null,
+ null,
+ row.value(),
+ subjId,
+ taskName,
+ !deserializeBinary);
+ }
}
+ else
+ skipEntry = false;
}
else
- skipEntry = false;
+ success = false;
}
- else
- success = false;
- }
- if (!skipEntry) {
- GridCacheEntryEx entry = null;
+ if (!skipEntry) {
+ GridCacheEntryEx entry = null;
- while (true) {
- try {
- entry = entryEx(cacheKey);
+ while (true) {
+ try {
+ entry = entryEx(cacheKey);
- if (entry != null) {
- CacheObject v;
+ if (entry != null) {
+ CacheObject v;
- if (needVer) {
- EntryGetResult res = entry.innerGetVersioned(
- null,
- null,
- /*update-metrics*/false,
- /*event*/evt,
- subjId,
- null,
- taskName,
- expiry,
- !deserializeBinary,
- null);
-
- if (res != null) {
- ctx.addResult(
- vals,
- cacheKey,
- res,
- skipVals,
- false,
- deserializeBinary,
- true,
- needVer);
+ if (needVer) {
+ EntryGetResult res =
entry.innerGetVersioned(
+ null,
+ null,
+ /*update-metrics*/false,
+ /*event*/evt,
+ subjId,
+ null,
+ taskName,
+ expiry,
+ !deserializeBinary,
+ null);
+
+ if (res != null) {
+ ctx.addResult(
+ vals,
+ cacheKey,
+ res,
+ skipVals,
+ false,
+ deserializeBinary,
+ true,
+ needVer);
+ }
+ else
+ success = false;
}
- else
- success = false;
- }
- else {
- v = entry.innerGet(
- null,
- null,
- /*read-through*/false,
- /*update-metrics*/true,
- /*event*/evt,
- subjId,
- null,
- taskName,
- expiry,
- !deserializeBinary);
-
- if (v != null) {
- ctx.addResult(vals,
- cacheKey,
- v,
- skipVals,
- false,
- deserializeBinary,
- true,
+ else {
+ v = entry.innerGet(
+ null,
null,
- 0,
- 0);
+ /*read-through*/false,
+ /*update-metrics*/true,
+ /*event*/evt,
+ subjId,
+ null,
+ taskName,
+ expiry,
+ !deserializeBinary);
+
+ if (v != null) {
+ ctx.addResult(vals,
+ cacheKey,
+ v,
+ skipVals,
+ false,
+ deserializeBinary,
+ true,
+ null,
+ 0,
+ 0);
+ }
+ else
+ success = false;
}
- else
- success = false;
}
+
+ break; // While.
+ }
+ catch (GridCacheEntryRemovedException ignored) {
+ // No-op, retry.
+ }
+ finally {
+ if (entry != null)
+ entry.touch();
}
- break; // While.
- }
- catch (GridCacheEntryRemovedException ignored) {
- // No-op, retry.
- }
- finally {
- if (entry != null)
- entry.touch();
+ if (!success && storeEnabled)
+ break;
}
-
- if (!success && storeEnabled)
- break;
+ }
+ if (!success) {
+ if (!storeEnabled && ctx.statisticsEnabled() && !skipVals)
+ metrics0().onRead(false);
}
}
- if (!success) {
- if (!storeEnabled && ctx.statisticsEnabled() && !skipVals)
- metrics0().onRead(false);
- }
+ }
+ finally {
+ ctx.shared().database().checkpointReadUnlock();
}
if (success || !storeEnabled)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
index 48622f2..c88bb5c 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
@@ -2707,19 +2707,24 @@ public class GridCacheOffheapManager extends
IgniteCacheOffheapManagerImpl imple
IgniteInClosure2X<GridCacheEntryEx, GridCacheVersion> c,
int amount
) throws IgniteCheckedException {
- GridDhtLocalPartition part =
cctx.topology().localPartition(partId, AffinityTopologyVersion.NONE, false,
false);
+ GridDhtLocalPartition part = null;
- // Skip non-owned partitions.
- if (part == null || part.state() != OWNING)
- return 0;
+ if (!grp.isLocal()) {
+ part = cctx.topology().localPartition(partId,
AffinityTopologyVersion.NONE, false, false);
+
+ // Skip non-owned partitions.
+ if (part == null || part.state() != OWNING)
+ return 0;
+ }
cctx.shared().database().checkpointReadLock();
+
try {
- if (!part.reserve())
+ if (part != null && !part.reserve())
return 0;
try {
- if (part.state() != OWNING)
+ if (part != null && part.state() != OWNING)
return 0;
long now = U.currentTimeMillis();
@@ -2765,7 +2770,8 @@ public class GridCacheOffheapManager extends
IgniteCacheOffheapManagerImpl imple
return cleared;
}
finally {
- part.release();
+ if (part != null)
+ part.release();
}
}
finally {
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 7451aad..823067c 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -1169,10 +1169,13 @@ public class IgniteTxManager extends
GridCacheSharedManagerAdapter {
private void removeObsolete(IgniteInternalTx tx) {
Collection<IgniteTxEntry> entries = tx.local() ? tx.allEntries() :
tx.writeEntries();
- for (IgniteTxEntry entry : entries) {
- cctx.database().checkpointReadLock();
+ if (F.isEmpty(entries))
+ return;
- try {
+ cctx.database().checkpointReadLock();
+
+ try {
+ for (IgniteTxEntry entry : entries) {
GridCacheEntryEx cached = entry.cached();
GridCacheContext cacheCtx = entry.context();
@@ -1200,10 +1203,11 @@ public class IgniteTxManager extends
GridCacheSharedManagerAdapter {
U.error(log, "Failed to remove obsolete entry from cache:
" + cached, e);
}
}
- finally {
- cctx.database().checkpointReadUnlock();
- }
}
+ finally {
+ cctx.database().checkpointReadUnlock();
+ }
+
}
/**
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWithTtlDeactivateOnHighloadTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWithTtlDeactivateOnHighloadTest.java
index 5e58e5b..47a5779 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWithTtlDeactivateOnHighloadTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsWithTtlDeactivateOnHighloadTest.java
@@ -17,23 +17,28 @@ package
org.apache.ignite.internal.processors.cache.persistence.db;
* limitations under the License.
*/
-import javax.cache.expiry.AccessedExpiryPolicy;
-import javax.cache.expiry.Duration;
+import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.cache.expiry.AccessedExpiryPolicy;
+import javax.cache.expiry.Duration;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CacheRebalanceMode;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.cluster.ClusterState;
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.NearCacheConfiguration;
import org.apache.ignite.configuration.WALMode;
import org.apache.ignite.failure.FailureContext;
import org.apache.ignite.failure.FailureHandler;
@@ -42,6 +47,7 @@ import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import
org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager;
+import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.testframework.MvccFeatureChecker;
@@ -49,6 +55,8 @@ import
org.apache.ignite.testframework.junits.WithSystemProperty;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.testframework.GridTestUtils.runAsync;
import static
org.apache.ignite.testframework.GridTestUtils.runMultiThreadedAsync;
import static org.apache.ignite.testframework.GridTestUtils.waitForAllFutures;
@@ -59,10 +67,22 @@ import static
org.apache.ignite.testframework.GridTestUtils.waitForAllFutures;
@WithSystemProperty(key =
IgniteSystemProperties.IGNITE_UNWIND_THROTTLING_TIMEOUT, value = "5")
public class IgnitePdsWithTtlDeactivateOnHighloadTest extends
GridCommonAbstractTest {
/** */
- private static final String CACHE_NAME = "expirable-cache";
+ private static final String CACHE_NAME_ATOMIC = "expirable-cache-atomic";
+
+ /** */
+ private static final String CACHE_NAME_TX = "expirable-cache-tx";
/** */
- private static final String GROUP_NAME = "group1";
+ private static final String CACHE_NAME_LOCAL_ATOMIC =
"expirable-cache-local-atomic";
+
+ /** */
+ private static final String CACHE_NAME_LOCAL_TX =
"expirable-cache-local-tx";
+
+ /** */
+ private static final String CACHE_NAME_NEAR_ATOMIC =
"expirable-cache-near-atomic";
+
+ /** */
+ private static final String CACHE_NAME_NEAR_TX = "expirable-cache-near-tx";
/** */
private static final int PART_SIZE = 2;
@@ -74,7 +94,7 @@ public class IgnitePdsWithTtlDeactivateOnHighloadTest extends
GridCommonAbstract
private static final int ENTRIES = 10;
/** */
- private static final int WORKLOAD_THREADS_CNT = 8;
+ private static final int WORKLOAD_THREADS_CNT = 16;
/** Fail. */
private volatile boolean fail;
@@ -111,7 +131,16 @@ public class IgnitePdsWithTtlDeactivateOnHighloadTest
extends GridCommonAbstract
.setPersistenceEnabled(true)
).setWalMode(WALMode.LOG_ONLY));
- cfg.setCacheConfiguration(getCacheConfiguration(CACHE_NAME));
+ cfg.setCacheConfiguration(
+ getCacheConfiguration(CACHE_NAME_ATOMIC).setAtomicityMode(ATOMIC),
+
getCacheConfiguration(CACHE_NAME_TX).setAtomicityMode(TRANSACTIONAL),
+
getCacheConfiguration(CACHE_NAME_LOCAL_ATOMIC).setAtomicityMode(ATOMIC).setCacheMode(CacheMode.LOCAL),
+
getCacheConfiguration(CACHE_NAME_LOCAL_TX).setAtomicityMode(TRANSACTIONAL).setCacheMode(CacheMode.LOCAL),
+
getCacheConfiguration(CACHE_NAME_NEAR_ATOMIC).setAtomicityMode(ATOMIC)
+ .setNearConfiguration(new NearCacheConfiguration<>()),
+
getCacheConfiguration(CACHE_NAME_NEAR_TX).setAtomicityMode(TRANSACTIONAL)
+ .setNearConfiguration(new NearCacheConfiguration<>())
+ );
return cfg;
}
@@ -133,11 +162,10 @@ public class IgnitePdsWithTtlDeactivateOnHighloadTest
extends GridCommonAbstract
* @param name Cache name.
* @return Cache configuration.
*/
- private CacheConfiguration getCacheConfiguration(String name) {
- CacheConfiguration ccfg = new CacheConfiguration();
+ private CacheConfiguration<?, ?> getCacheConfiguration(String name) {
+ CacheConfiguration<?, ?> ccfg = new CacheConfiguration<>();
ccfg.setName(name);
- ccfg.setGroupName(GROUP_NAME);
ccfg.setAffinity(new RendezvousAffinityFunction(false, PART_SIZE));
ccfg.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new
Duration(TimeUnit.MILLISECONDS, EXPIRATION_TIMEOUT)));
ccfg.setEagerTtl(true);
@@ -151,20 +179,21 @@ public class IgnitePdsWithTtlDeactivateOnHighloadTest
extends GridCommonAbstract
* @throws Exception if failed.
*/
@Test
+ @SuppressWarnings("LockAcquiredButNotSafelyReleased")
public void
shouldNotBeProblemToPutToExpiredCacheConcurrentlyWithCheckpoint() throws
Exception {
IgniteEx ig0 = startGrid(0);
- ig0.cluster().active(true);
+ ig0.cluster().state(ClusterState.ACTIVE);
- IgniteCache<Object, Object> cache = ig0.getOrCreateCache(CACHE_NAME);
+ IgniteCache<Object, Object> cache =
ig0.getOrCreateCache(CACHE_NAME_ATOMIC);
AtomicBoolean timeoutReached = new AtomicBoolean(false);
GridCacheDatabaseSharedManager db =
(GridCacheDatabaseSharedManager)ig0.context().cache().context().database();
- IgniteInternalFuture ldrFut = runMultiThreadedAsync(() -> {
+ IgniteInternalFuture<?> ldrFut = runMultiThreadedAsync(() -> {
while (!timeoutReached.get()) {
- Map map = new TreeMap();
+ Map<Object, Object> map = new TreeMap<>();
for (int i = 0; i < ENTRIES; i++)
map.put(i, i);
@@ -173,14 +202,14 @@ public class IgnitePdsWithTtlDeactivateOnHighloadTest
extends GridCommonAbstract
}
}, WORKLOAD_THREADS_CNT, "loader");
- IgniteInternalFuture updaterFut = runMultiThreadedAsync(() -> {
+ IgniteInternalFuture<?> updaterFut = runMultiThreadedAsync(() -> {
while (!timeoutReached.get()) {
for (int i = 0; i < ENTRIES; i++)
cache.put(i, i * 10);
}
}, WORKLOAD_THREADS_CNT, "updater");
- IgniteInternalFuture cpWriteLockUnlockFut = runAsync(() -> {
+ IgniteInternalFuture<?> cpWriteLockUnlockFut = runAsync(() -> {
ReentrantReadWriteLock lock = U.field(db, "checkpointLock");
while (!timeoutReached.get()) {
@@ -214,21 +243,33 @@ public class IgnitePdsWithTtlDeactivateOnHighloadTest
extends GridCommonAbstract
public void shouldNotBeProblemToPutToExpiredCacheConcurrently() throws
Exception {
final AtomicBoolean end = new AtomicBoolean();
- final IgniteEx srv = startGrid(0);
+ final IgniteEx srv = startGrids(3);
+
+ srv.cluster().state(ClusterState.ACTIVE);
- srv.cluster().active(true);
+ // Start high workload.
+ IgniteInternalFuture<?> loadFut = runMultiThreadedAsync(() -> {
+ List<IgniteCache<Object, Object>> caches = F.asList(
+ srv.cache(CACHE_NAME_ATOMIC),
+ srv.cache(CACHE_NAME_TX),
+ srv.cache(CACHE_NAME_LOCAL_ATOMIC),
+ srv.cache(CACHE_NAME_LOCAL_TX),
+ srv.cache(CACHE_NAME_NEAR_ATOMIC),
+ srv.cache(CACHE_NAME_NEAR_TX)
+ );
- // Start high workload
- IgniteInternalFuture loadFut = runMultiThreadedAsync(() -> {
while (!end.get() && !fail) {
- IgniteCache<Integer, byte[]> cache = srv.cache(CACHE_NAME);
+ for (IgniteCache<Object, Object> cache : caches) {
+ for (int i = 0; i < ENTRIES; i++)
+ cache.put(i, new byte[1024]);
- for (int i = 0; i < ENTRIES; i++)
- cache.put(i, new byte[1024]);
+ cache.putAll(new TreeMap<>(F.asMap(0, new byte[1024], 1,
new byte[1024])));
- //Touch entries.
- for (int i = 0; i < ENTRIES; i++)
- cache.get(i); // touch entries
+ for (int i = 0; i < ENTRIES; i++)
+ cache.get(i);
+
+ cache.getAll(new TreeSet<>(F.asList(0, 1)));
+ }
}
}, WORKLOAD_THREADS_CNT, "high-workload");
@@ -247,14 +288,4 @@ public class IgnitePdsWithTtlDeactivateOnHighloadTest
extends GridCommonAbstract
assertFalse("Failure handler was called. See log above.", fail);
}
-
- /** */
- protected void fillCache(IgniteCache<Integer, byte[]> cache) {
- for (int i = 0; i < ENTRIES; i++)
- cache.put(i, new byte[1024]);
-
- //Touch entries.
- for (int i = 0; i < ENTRIES; i++)
- cache.get(i); // touch entries
- }
}