You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by il...@apache.org on 2019/03/27 16:41:29 UTC
[ignite] branch master updated: IGNITE-11127 Handling
GridDhtInvalidPartitionException by GridCacheTtlManager - Fixes #6338.
This is an automated email from the ASF dual-hosted git repository.
ilyak 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 fd394d8 IGNITE-11127 Handling GridDhtInvalidPartitionException by GridCacheTtlManager - Fixes #6338.
fd394d8 is described below
commit fd394d89dd8c66b7f5db609dbcc470d24006955d
Author: shroman <rs...@yahoo.com>
AuthorDate: Wed Mar 27 19:40:47 2019 +0300
IGNITE-11127 Handling GridDhtInvalidPartitionException by GridCacheTtlManager - Fixes #6338.
Signed-off-by: Ilya Kasnacheev <il...@gmail.com>
---
.../processors/cache/GridCacheTtlManager.java | 7 ++
.../IgniteCacheExpireWhileRebalanceTest.java | 121 +++++++++++++++++++++
.../expiry/IgniteCacheExpiryPolicyTestSuite.java | 4 +-
3 files changed, 131 insertions(+), 1 deletion(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java
index f82cc75..65d500c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheTtlManager.java
@@ -23,6 +23,7 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.NodeStoppingException;
+import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtInvalidPartitionException;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -244,6 +245,12 @@ public class GridCacheTtlManager extends GridCacheManagerAdapter {
return e != null && e.expireTime <= now;
}
}
+ catch (GridDhtInvalidPartitionException e) {
+ if (log.isDebugEnabled())
+ log.debug("Partition became invalid during rebalancing (will ignore): " + e.partition());
+
+ return false;
+ }
catch (IgniteCheckedException e) {
U.error(log, "Failed to process entry expiration: " + e, e);
}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpireWhileRebalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpireWhileRebalanceTest.java
new file mode 100644
index 0000000..7745e4b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpireWhileRebalanceTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.expiry;
+
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.failure.StopNodeOrHaltFailureHandler;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import javax.cache.expiry.CreatedExpiryPolicy;
+import javax.cache.expiry.Duration;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+
+/**
+ * Expiration while writing and rebalancing.
+ */
+public class IgniteCacheExpireWhileRebalanceTest extends GridCommonAbstractTest {
+ /** */
+ private static final int ENTRIES = 100000;
+
+ /** */
+ private static final int CLUSTER_SIZE = 4;
+
+ /**
+ * Finder.
+ */
+ protected static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+ cfg.setFailureHandler(new StopNodeOrHaltFailureHandler());
+
+ CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
+
+ ccfg.setAtomicityMode(ATOMIC);
+ ccfg.setCacheMode(PARTITIONED);
+ ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1)));
+
+ cfg.setCacheConfiguration(ccfg);
+
+ return cfg;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testExpireWhileRebalancing() throws Exception {
+ startGridsMultiThreaded(CLUSTER_SIZE);
+
+ IgniteCache<Object, Object> cache = ignite(0).cache(DEFAULT_CACHE_NAME);
+
+ CountDownLatch latch = new CountDownLatch(1);
+
+ new Thread(() -> {
+ for (int i = 1; i <= ENTRIES; i++) {
+ cache.put(i, i);
+
+ if (i % (ENTRIES / 10) == 0)
+ System.out.println(">>> Entries put: " + i);
+ }
+ latch.countDown();
+ }).start();
+
+ stopGrid(CLUSTER_SIZE - 1);
+
+ awaitPartitionMapExchange();
+
+ startGrid(CLUSTER_SIZE - 1);
+
+ latch.await(10, TimeUnit.SECONDS);
+
+ int resultingSize = cache.size(CachePeekMode.PRIMARY);
+
+ System.out.println(">>> Resulting size: " + resultingSize);
+
+ assertTrue(resultingSize > 0);
+
+ // Eviction started
+ assertTrue(resultingSize < ENTRIES * 10 / 11);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java
index 681cca5..b54c26d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java
@@ -56,7 +56,9 @@ import org.junit.runners.Suite;
// Eager ttl expiration tests.
GridCacheTtlManagerNotificationTest.class,
- IgniteCacheOnlyOneTtlCleanupThreadExistsTest.class
+ IgniteCacheOnlyOneTtlCleanupThreadExistsTest.class,
+
+ IgniteCacheExpireWhileRebalanceTest.class
})
public class IgniteCacheExpiryPolicyTestSuite {
}