You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by jo...@apache.org on 2019/09/24 16:05:08 UTC
[ignite] branch master updated: IGNITE-12206 Skip partition states
validation if custom expiry policy is set. - Fixes #6888.
This is an automated email from the ASF dual-hosted git repository.
jokser 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 b31c9dc IGNITE-12206 Skip partition states validation if custom expiry policy is set. - Fixes #6888.
b31c9dc is described below
commit b31c9dc58b68d6695ed53e719c63be15222ab7b4
Author: mstepachev <ma...@gmail.com>
AuthorDate: Tue Sep 24 19:03:59 2019 +0300
IGNITE-12206 Skip partition states validation if custom expiry policy is set. - Fixes #6888.
Signed-off-by: Pavel Kovalenko <jo...@gmail.com>
---
.../preloader/GridDhtPartitionsExchangeFuture.java | 11 +-
.../DiagnosticLogForPartitionStatesTest.java | 129 +++++++++++++++++++++
.../ignite/testsuites/IgniteBasicTestSuite.java | 2 +
3 files changed, 140 insertions(+), 2 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index e7c69a8..334a575 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -42,6 +42,7 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import javax.cache.expiry.EternalExpiryPolicy;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
@@ -148,6 +149,9 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
/** */
public static final String EXCHANGE_LOG = "org.apache.ignite.internal.exchange.time";
+ /** Partition state failed message. */
+ public static final String PARTITION_STATE_FAILED_MSG = "Partition states validation has failed for group: %s, msg: %s";
+
/** */
private static final int RELEASE_FUTURE_DUMP_THRESHOLD =
IgniteSystemProperties.getInteger(IGNITE_PARTITION_RELEASE_FUTURE_DUMP_THRESHOLD, 0);
@@ -3762,13 +3766,16 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
// Do not validate read or write through caches or caches with disabled rebalance
// or ExpiryPolicy is set or validation is disabled.
+ boolean eternalExpiryPolicy = grpCtx != null && (grpCtx.config().getExpiryPolicyFactory() == null
+ || grpCtx.config().getExpiryPolicyFactory().create() instanceof EternalExpiryPolicy);
+
if (grpCtx == null
|| grpCtx.config().isReadThrough()
|| grpCtx.config().isWriteThrough()
|| grpCtx.config().getCacheStoreFactory() != null
|| grpCtx.config().getRebalanceDelay() == -1
|| grpCtx.config().getRebalanceMode() == CacheRebalanceMode.NONE
- || grpCtx.config().getExpiryPolicyFactory() == null
+ || !eternalExpiryPolicy
|| SKIP_PARTITION_SIZE_VALIDATION)
return null;
@@ -3776,7 +3783,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
validator.validatePartitionCountersAndSizes(GridDhtPartitionsExchangeFuture.this, top, msgs);
}
catch (IgniteCheckedException ex) {
- log.warning("Partition states validation has failed for group: " + grpCtx.cacheOrGroupName() + ". " + ex.getMessage());
+ log.warning(String.format(PARTITION_STATE_FAILED_MSG, grpCtx.cacheOrGroupName(), ex.getMessage()));
// TODO: Handle such errors https://issues.apache.org/jira/browse/IGNITE-7833
}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/DiagnosticLogForPartitionStatesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/DiagnosticLogForPartitionStatesTest.java
new file mode 100644
index 0000000..ac9af91
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/DiagnosticLogForPartitionStatesTest.java
@@ -0,0 +1,129 @@
+/*
+ * 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;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import javax.cache.expiry.AccessedExpiryPolicy;
+import javax.cache.expiry.Duration;
+import org.apache.ignite.IgniteCache;
+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.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.apache.ignite.testframework.junits.GridAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.After;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.PARTITION_STATE_FAILED_MSG;
+
+/**
+ * Checks diagnostic messages at PME.
+ */
+public class DiagnosticLogForPartitionStatesTest extends GridCommonAbstractTest {
+ /** Cache 1. */
+ private static final String CACHE_1 = "cache-1";
+
+ /** Any message. */
+ private static final String ANY_MSG = "";
+
+ /** Test logger. */
+ private final ListeningTestLogger log = new ListeningTestLogger(false, GridAbstractTest.log);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ return super.getConfiguration(igniteInstanceName)
+ .setGridLogger(log)
+ .setConsistentId(igniteInstanceName)
+ .setDataStorageConfiguration(new DataStorageConfiguration()
+ .setDefaultDataRegionConfiguration(new DataRegionConfiguration()
+ .setPersistenceEnabled(true)
+ .setMaxSize(200L * 1024 * 1024)));
+ }
+
+ /**
+ * @throws Exception if stopAllGrid fails.
+ */
+ @After
+ public void tearDown() throws Exception {
+ stopAllGrids();
+ cleanPersistenceDir();
+ }
+
+ /**
+ *
+ */
+ @Test
+ public void shouldPrintMessageIfPartitionHasOtherCounter() throws Exception {
+ doTest(new CacheConfiguration<>(CACHE_1).setBackups(1), true);
+ }
+
+ /**
+ *
+ */
+ @Test
+ public void shouldNotPrintMessageIfPartitionHasOtherCounterButHasCustomExpiryPolicy() throws Exception {
+ doTest(
+ new CacheConfiguration<>(CACHE_1)
+ .setBackups(1)
+ .setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1))),
+ false
+ );
+ }
+
+ /**
+ * @param cacheCfg Cache config.
+ * @param msgExp Message expected.
+ */
+ private void doTest(CacheConfiguration<Object, Object> cacheCfg, boolean msgExp) throws Exception {
+ LogListener lsnr = LogListener.matches(s -> s.startsWith(String.format(PARTITION_STATE_FAILED_MSG, CACHE_1, ANY_MSG)))
+ .times(msgExp ? 1 : 0).build();
+
+ log.registerListener(lsnr);
+
+ IgniteEx node1 = startGrid(0);
+
+ IgniteEx node2 = startGrid(1);
+
+ node1.cluster().active(true);
+
+ IgniteCache<Object, Object> cache = node1.getOrCreateCache(cacheCfg);
+
+ Set<Integer> clearKeys = new HashSet<>();
+
+ for (int i = 0; i < 100; i++) {
+ cache.put(i, i);
+
+ if (node2.affinity(CACHE_1).isPrimary(node2.localNode(), i))
+ clearKeys.add(i);
+ }
+
+ node2.context().cache().cache(CACHE_1).clearLocallyAll(clearKeys, true, true, true);
+
+ //do exchange for validation trigger
+ startGrid(2);
+
+ awaitPartitionMapExchange();
+
+ assertTrue(lsnr.check());
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index 6f040ff..bf40264 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.ClusterGroupHostsSelfTest;
import org.apache.ignite.internal.ClusterGroupSelfTest;
import org.apache.ignite.internal.ClusterProcessorCheckGlobalStateComputeRequestTest;
import org.apache.ignite.internal.ConsistentIdImplicitlyExplicitlyTest;
+import org.apache.ignite.internal.DiagnosticLogForPartitionStatesTest;
import org.apache.ignite.internal.GridFailFastNodeFailureDetectionSelfTest;
import org.apache.ignite.internal.GridLifecycleAwareSelfTest;
import org.apache.ignite.internal.GridLifecycleBeanSelfTest;
@@ -254,6 +255,7 @@ import org.junit.runners.Suite;
BaselineAutoAdjustMXBeanTest.class,
ConsistentIdImplicitlyExplicitlyTest.class,
+ DiagnosticLogForPartitionStatesTest.class,
// Tests against configuration variations framework.
ParametersTest.class,