Repository: ignite Updated Branches: refs/heads/ignite-2.5 06f89322e -> c7866f0dc
IGNITE-8358 Destroy partition inside evictor to prevent possible deadlock. This closes #3911. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c7866f0d Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c7866f0d Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c7866f0d Branch: refs/heads/ignite-2.5 Commit: c7866f0dccef77b9f13bdbde4d36a1e789789b72 Parents: 06f8932 Author: Pavel Kovalenko <[email protected]> Authored: Wed Apr 25 17:39:02 2018 +0300 Committer: Alexey Goncharuk <[email protected]> Committed: Wed Apr 25 17:39:38 2018 +0300 ---------------------------------------------------------------------- .../distributed/dht/GridDhtLocalPartition.java | 21 ++++++++++++-------- .../dht/GridDhtPartitionsEvictor.java | 6 +++++- 2 files changed, 18 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/c7866f0d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java index ea20dbf..be74eff 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java @@ -31,7 +31,6 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.cluster.ClusterNode; -import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.NodeStoppingException; import org.apache.ignite.internal.pagemem.wal.record.delta.PartitionMetaStateRecord; @@ -164,6 +163,9 @@ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements /** Set if partition must be cleared in MOVING state. */ private volatile boolean clear; + /** Set if topology update sequence should be updated on partition destroy. */ + private boolean updateSeqOnDestroy; + /** * @param ctx Context. * @param grp Cache group. @@ -664,6 +666,12 @@ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements if (partState == RENTING && casState(state, EVICTED) || clearingRequested) { clearFuture.finish(); + if (state() == EVICTED && markForDestroy()) { + updateSeqOnDestroy = updateSeq; + + destroy(); + } + return; } } @@ -744,7 +752,7 @@ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements /** * @return {@code True} if partition is safe to destroy. */ - private boolean markForDestroy() { + public boolean markForDestroy() { while (true) { int cnt = evictGuard.get(); @@ -771,17 +779,14 @@ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements if (log.isDebugEnabled()) log.debug("Evicted partition: " + this); - if (markForDestroy()) - finishDestroy(updateSeq); + updateSeqOnDestroy = updateSeq; } } /** * Destroys partition data store and invokes appropriate callbacks. - * - * @param updateSeq If {@code true} increment update sequence on cache group topology after successful destroy. */ - private void finishDestroy(boolean updateSeq) { + public void destroy() { assert state() == EVICTED : this; assert evictGuard.get() == -1; @@ -791,7 +796,7 @@ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements rent.onDone(); - ((GridDhtPreloader)grp.preloader()).onPartitionEvicted(this, updateSeq); + ((GridDhtPreloader)grp.preloader()).onPartitionEvicted(this, updateSeqOnDestroy); clearDeferredDeletes(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/c7866f0d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsEvictor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsEvictor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsEvictor.java index 3e51ff3..2a28921 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsEvictor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsEvictor.java @@ -94,8 +94,12 @@ public class GridDhtPartitionsEvictor { try { boolean success = part.tryClear(); - if (success) + if (success) { evictionQueue.remove(part.id()); + + if (part.state() == GridDhtPartitionState.EVICTED && part.markForDestroy()) + part.destroy(); + } } catch (Throwable ex) { if (ctx.kernalContext().isStopping()) {
