Repository: ignite
Updated Branches:
  refs/heads/ignite-5937 3255ce228 -> 7bb94f529


ignite-5937


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7bb94f52
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7bb94f52
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7bb94f52

Branch: refs/heads/ignite-5937
Commit: 7bb94f529678a0015bae2ac4e0c4658e6fc616f5
Parents: 3255ce2
Author: sboikov <[email protected]>
Authored: Wed Oct 11 11:06:45 2017 +0300
Committer: sboikov <[email protected]>
Committed: Wed Oct 11 11:17:14 2017 +0300

----------------------------------------------------------------------
 .../transactions/IgniteTxLocalAdapter.java      | 26 ++++++++++----
 .../cache/mvcc/CacheMvccTransactionsTest.java   | 38 ++++++++++++++++++++
 2 files changed, 57 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7bb94f52/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index 92e6785..d8f911c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -707,12 +707,7 @@ public abstract class IgniteTxLocalAdapter extends 
IgniteTxAdapter implements Ig
 
                                             GridLongList waitTxs = 
updRes.mvccWaitTransactions();
 
-                                            if (waitTxs != null) {
-                                                if (this.mvccWaitTxs == null)
-                                                    this.mvccWaitTxs = waitTxs;
-                                                else
-                                                    
this.mvccWaitTxs.addAll(waitTxs);
-                                            }
+                                            updateWaitTxs(waitTxs);
                                         }
 
                                         if (nearCached != null && 
updRes.success()) {
@@ -762,9 +757,14 @@ public abstract class IgniteTxLocalAdapter extends 
IgniteTxAdapter implements Ig
                                             null,
                                             mvccInfo != null ? 
mvccInfo.version() : null);
 
-                                        if (updRes.success())
+                                        if (updRes.success()) {
                                             
txEntry.updateCounter(updRes.updatePartitionCounter());
 
+                                            GridLongList waitTxs = 
updRes.mvccWaitTransactions();
+
+                                            updateWaitTxs(waitTxs);
+                                        }
+
                                         if (nearCached != null && 
updRes.success()) {
                                             nearCached.innerRemove(
                                                 null,
@@ -924,6 +924,18 @@ public abstract class IgniteTxLocalAdapter extends 
IgniteTxAdapter implements Ig
     }
 
     /**
+     * @param waitTxs Tx ids to wait for.
+     */
+    private void updateWaitTxs(@Nullable GridLongList waitTxs) {
+        if (waitTxs != null) {
+            if (this.mvccWaitTxs == null)
+                this.mvccWaitTxs = waitTxs;
+            else
+                this.mvccWaitTxs.addAll(waitTxs);
+        }
+    }
+
+    /**
      * Commits transaction to transaction manager. Used for one-phase commit 
transactions only.
      *
      * @param commit If {@code true} commits transaction, otherwise rollbacks.

http://git-wip-us.apache.org/repos/asf/ignite/blob/7bb94f52/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
index 35ceed1..b63ae51 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
@@ -454,6 +454,41 @@ public class CacheMvccTransactionsTest extends 
GridCommonAbstractTest {
         }
 
         checkValues(expVals, cache);
+
+        ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+        Object key = testKey(largeKeys, 0);
+
+        for (int i = 0; i < 500; i++) {
+            boolean rmvd;
+
+            try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+                if (rnd.nextBoolean()) {
+                    cache.remove(key);
+
+                    rmvd = true;
+                }
+                else {
+                    cache.put(key, i);
+
+                    rmvd = false;
+                }
+
+                tx.commit();
+            }
+
+            if (rmvd) {
+                assertNull(cache.get(key));
+                assertTrue(cache.getAll(F.asSet(key)).isEmpty());
+            }
+            else {
+                assertEquals(i, cache.get(key));
+
+                Map<Object, Object> res = cache.getAll(F.asSet(key));
+
+                assertEquals(i, res.get(key));
+            }
+        }
     }
 
     /**
@@ -476,6 +511,9 @@ public class CacheMvccTransactionsTest extends 
GridCommonAbstractTest {
      * @param cache Cache.
      */
     private void checkValues(Map<Object, Object> expVals, IgniteCache<Object, 
Object> cache) {
+        for (Map.Entry<Object, Object> e : expVals.entrySet())
+            assertEquals(e.getValue(), cache.get(e.getKey()));
+
         Map<Object, Object> res = cache.getAll(expVals.keySet());
 
         assertEquals(expVals, res);

Reply via email to