This is an automated email from the ASF dual-hosted git repository.

agoncharuk 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 0282210  IGNITE-11050 Fixed potential deadlock due to 
DhtColocatedLockFuture#map being called inside topology read lock - Fixes #6015.
0282210 is described below

commit 0282210b01691dd268ce66e650dfd25f54c261c1
Author: mstepachev <maksim.stepac...@gmail.com>
AuthorDate: Tue Feb 26 16:00:07 2019 +0300

    IGNITE-11050 Fixed potential deadlock due to DhtColocatedLockFuture#map 
being called inside topology read lock - Fixes #6015.
    
    Signed-off-by: Alexey Goncharuk <alexey.goncha...@gmail.com>
---
 .../dht/colocated/GridDhtColocatedLockFuture.java  | 73 +++++++++++-----------
 1 file changed, 36 insertions(+), 37 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index fec572e..25989e9 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -155,9 +155,6 @@ public final class GridDhtColocatedLockFuture extends 
GridCacheCompoundIdentityF
     /** */
     private volatile int done;
 
-    /** Trackable flag (here may be non-volatile). */
-    private boolean trackable;
-
     /** TTL for create operation. */
     private final long createTtl;
 
@@ -266,12 +263,12 @@ public final class GridDhtColocatedLockFuture extends 
GridCacheCompoundIdentityF
 
     /** {@inheritDoc} */
     @Override public boolean trackable() {
-        return trackable;
+        return true;
     }
 
     /** {@inheritDoc} */
     @Override public void markNotTrackable() {
-        trackable = false;
+        throw new UnsupportedOperationException();
     }
 
     /**
@@ -807,6 +804,8 @@ public final class GridDhtColocatedLockFuture extends 
GridCacheCompoundIdentityF
                     this.topVer = topVer;
             }
 
+            cctx.mvcc().addFuture(this);
+
             map(keys, false, true);
 
             markInitialized();
@@ -829,6 +828,10 @@ public final class GridDhtColocatedLockFuture extends 
GridCacheCompoundIdentityF
         // We must acquire topology snapshot from the topology version future.
         cctx.topology().readLock();
 
+        final GridDhtTopologyFuture fut;
+
+        final boolean finish;
+
         try {
             if (cctx.topology().stopping()) {
                 onDone(
@@ -839,9 +842,11 @@ public final class GridDhtColocatedLockFuture extends 
GridCacheCompoundIdentityF
                 return;
             }
 
-            GridDhtTopologyFuture fut = cctx.topologyVersionFuture();
+            fut = cctx.topologyVersionFuture();
 
-            if (fut.isDone()) {
+            finish = fut.isDone();
+
+            if (finish) {
                 Throwable err = fut.validateCache(cctx, recovery, read, null, 
keys);
 
                 if (err != null) {
@@ -870,30 +875,35 @@ public final class GridDhtColocatedLockFuture extends 
GridCacheCompoundIdentityF
                     }
                 }
 
-                map(keys, remap, false);
-
-                if (c != null)
-                    c.run();
-
-                markInitialized();
-            }
-            else {
-                cctx.time().waitAsync(fut, tx == null ? 0 : 
tx.remainingTime(), (e, timedOut) -> {
-                    if (errorOrTimeoutOnTopologyVersion(e, timedOut))
-                        return;
-
-                    try {
-                        mapOnTopology(remap, c);
-                    }
-                    finally {
-                        cctx.shared().txContextReset();
-                    }
-                });
+                if (!remap)
+                    cctx.mvcc().addFuture(this);
             }
         }
         finally {
             cctx.topology().readUnlock();
         }
+
+        if (finish) {
+            map(keys, remap, false);
+
+            if (c != null)
+                c.run();
+
+            markInitialized();
+        }
+        else {
+            cctx.time().waitAsync(fut, tx == null ? 0 : tx.remainingTime(), 
(e, timedOut) -> {
+                if (errorOrTimeoutOnTopologyVersion(e, timedOut))
+                    return;
+
+                try {
+                    mapOnTopology(remap, c);
+                }
+                finally {
+                    cctx.shared().txContextReset();
+                }
+            });
+        }
     }
 
     /**
@@ -1139,15 +1149,6 @@ public final class GridDhtColocatedLockFuture extends 
GridCacheCompoundIdentityF
                     iter.remove();
                 }
             }
-
-            if (hasRmtNodes) {
-                trackable = true;
-
-                if (!remap && !cctx.mvcc().addFuture(this))
-                    throw new IllegalStateException("Duplicate future ID: " + 
this);
-            }
-            else
-                trackable = false;
         }
         finally {
             /** Notify ready {@link mappings} waiters. See {@link #cancel()} */
@@ -1388,8 +1389,6 @@ public final class GridDhtColocatedLockFuture extends 
GridCacheCompoundIdentityF
                 return true;
         }
 
-        trackable = false;
-
         if (tx != null) {
             if (explicit)
                 tx.markExplicit(cctx.localNodeId());

Reply via email to