You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/12/30 14:07:16 UTC
ignite git commit: Attempt to fix race between cache start and start
future completion.
Repository: ignite
Updated Branches:
refs/heads/ignite-3477 a940fc3ad -> 81ba60fc3
Attempt to fix race between cache start and start future completion.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/81ba60fc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/81ba60fc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/81ba60fc
Branch: refs/heads/ignite-3477
Commit: 81ba60fc38f6a880a3771ab50de31ff027f12811
Parents: a940fc3
Author: sboikov <sb...@gridgain.com>
Authored: Fri Dec 30 17:07:12 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Dec 30 17:07:12 2016 +0300
----------------------------------------------------------------------
.../processors/cache/DynamicCacheDescriptor.java | 17 +++++++++++++++++
.../processors/cache/GridCacheProcessor.java | 17 +++++++++++++++--
.../preloader/GridDhtPartitionsExchangeFuture.java | 11 ++++++-----
...WriteSynchronizationModesMultithreadedTest.java | 2 +-
4 files changed, 39 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/81ba60fc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
index 8b62f03..5938785 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
@@ -81,6 +81,9 @@ public class DynamicCacheDescriptor {
/** */
private AffinityTopologyVersion rcvdFromVer;
+ /** */
+ private transient AffinityTopologyVersion clientCacheStartVer;
+
/**
* @param ctx Context.
* @param cacheCfg Cache configuration.
@@ -302,6 +305,20 @@ public class DynamicCacheDescriptor {
return rcvdFrom;
}
+ /**
+ * @return Version when client cache on local node was started.
+ */
+ @Nullable AffinityTopologyVersion clientCacheStartVersion() {
+ return clientCacheStartVer;
+ }
+
+ /**
+ * @param clientCacheStartVer Version when client cache on local node was started.
+ */
+ public void clientCacheStartVersion(AffinityTopologyVersion clientCacheStartVer) {
+ this.clientCacheStartVer = clientCacheStartVer;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(DynamicCacheDescriptor.class, this, "cacheName", U.maskName(cacheCfg.getName()));
http://git-wip-us.apache.org/repos/asf/ignite/blob/81ba60fc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 53807f5..11e31ec 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -2939,10 +2939,23 @@ public class GridCacheProcessor extends GridProcessorAdapter {
req.clientStartOnly(true);
}
}
+
+ if (needExchange) {
+ if (newTopVer == null) {
+ newTopVer = new AffinityTopologyVersion(topVer.topologyVersion(),
+ topVer.minorTopologyVersion() + 1);
+ }
+
+ desc.clientCacheStartVersion(newTopVer);
+ }
}
- if (!needExchange && desc != null)
- req.cacheFutureTopologyVersion(desc.startTopologyVersion());
+ if (!needExchange && desc != null) {
+ if (desc.clientCacheStartVersion() != null)
+ req.cacheFutureTopologyVersion(desc.clientCacheStartVersion());
+ else
+ req.cacheFutureTopologyVersion(desc.startTopologyVersion());
+ }
}
else if (req.globalStateChange() || req.resetLostPartitions())
needExchange = true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/81ba60fc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
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 53c2dbc..e2c6b49 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
@@ -1174,9 +1174,10 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
cctx.exchange().onExchangeDone(this, err);
- if (!F.isEmpty(reqs) && err == null)
+ if (!F.isEmpty(reqs) && err == null) {
for (DynamicCacheChangeRequest req : reqs)
cctx.cache().completeStartFuture(req);
+ }
if (exchangeOnChangeGlobalState && err == null)
cctx.kernalContext().state().onExchangeDone();
@@ -1221,10 +1222,10 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
return new CacheInvalidStateException(
"Failed to perform cache operation (cluster is not activated): " + cctx.name());
- PartitionLossPolicy partLossPolicy = cctx.config().getPartitionLossPolicy();
+ PartitionLossPolicy partLossPlc = cctx.config().getPartitionLossPolicy();
if (cctx.needsRecovery() && !recovery) {
- if (!read && (partLossPolicy == READ_ONLY_SAFE || partLossPolicy == READ_ONLY_ALL))
+ if (!read && (partLossPlc == READ_ONLY_SAFE || partLossPlc == READ_ONLY_ALL))
return new IgniteCheckedException("Failed to write to cache (cache is moved to a read-only state): " +
cctx.name());
}
@@ -1246,7 +1247,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
int p = cctx.affinity().partition(key);
CacheInvalidStateException ex = validatePartitionOperation(cctx.name(), read, key, p,
- validation.lostParts, partLossPolicy);
+ validation.lostParts, partLossPlc);
if (ex != null)
return ex;
@@ -1257,7 +1258,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
int p = cctx.affinity().partition(k);
CacheInvalidStateException ex = validatePartitionOperation(cctx.name(), read, k, p,
- validation.lostParts, partLossPolicy);
+ validation.lostParts, partLossPlc);
if (ex != null)
return ex;
http://git-wip-us.apache.org/repos/asf/ignite/blob/81ba60fc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java
index 08396da..c87d3ea 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxCacheWriteSynchronizationModesMultithreadedTest.java
@@ -313,7 +313,7 @@ public class IgniteTxCacheWriteSynchronizationModesMultithreadedTest extends Gri
* @param c Test iteration closure.
* @throws Exception If failed.
*/
- public void commitMultithreaded(final IgniteBiInClosure<Ignite, IgniteCache<Integer, Integer>> c) throws Exception {
+ private void commitMultithreaded(final IgniteBiInClosure<Ignite, IgniteCache<Integer, Integer>> c) throws Exception {
final long stopTime = System.currentTimeMillis() + 10_000;
GridTestUtils.runMultiThreaded(new IgniteInClosure<Integer>() {